Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct processing of backtick code block on blockquote (fix Issue#2969) #3765

Conversation

seaoak
Copy link
Member

@seaoak seaoak commented Oct 14, 2019

What does it do?

Fix #2969

This patch makes the filter "backtick_code_block" to remove '>' characters at the head of each line.
How many '>' characters should be removed?
It is decided by the number of '>' characters at the first line.
This patch works well even if there are too few '>' characters at the head of a line.
(Simply removes all '>' characters less than or equal to the number of '>' characters at the first lines.)

Note that this patch works well for a "lang=dos" or "lang=cmd" code block.
The body of these code blocks is usually starting with '>' (DOS prompt).
This patch keeps it if it follows '>' characters which is the same number of the first line.

For example,

> Hello
> 
> ```dos
> > dir
> ```

is rendered to:

<p>Hello</p>
<blockquote>
<pre><code>&gt; dir</code></pre>
</blockquote>

This PR is an alternative of the PR hexojs/hexo-util#110

Pull request tasks

  • Add test cases for the changes.
  • Passed the CI test.

This patch makes the filter "backtick_code_block" to remove '>' characters at the head of each line.
How many '>' characters should be removed?
It is decided by the number of '>' characters at the first line.
This patch works well even if there are too few '>' characters at the head of a line.
(Simply removes all '>' characters less than or equal to the number of '>' characters at the first lines.)
@coveralls
Copy link

coveralls commented Oct 14, 2019

Coverage Status

Coverage increased (+0.005%) to 97.283% when pulling deaad6b on seaoak:feature/correct_filter_backtick_code_block_on_blockquote into 79bdc95 on hexojs:master.

@seaoak seaoak requested review from curbengh and a team October 14, 2019 07:54
@curbengh
Copy link
Contributor

I can confirm it also works with

> > ```html
> <b>test</b>
> > ```

curbengh
curbengh previously approved these changes Oct 14, 2019
@curbengh curbengh added this to In progress in v4.0.0 via automation Oct 14, 2019
@curbengh curbengh added this to the v4.0.0 milestone Oct 14, 2019
@curbengh
Copy link
Contributor

also confirmed it works with,

``` cmd
> ipconfig
```

@curbengh curbengh merged commit 6b329e9 into hexojs:master Oct 14, 2019
v4.0.0 automation moved this from In progress to Done Oct 14, 2019
seaoak added a commit to seaoak/hexo that referenced this pull request Oct 16, 2019
Blank lines in backtick code block on blockquote should be kept.
But `backtick_code_block.js` removes them.
This patch fixes this behavior.
This bug is introduced by the PR hexojs#3765
thom4parisot pushed a commit to thom4parisot/hexo that referenced this pull request Jan 17, 2020
thom4parisot pushed a commit to thom4parisot/hexo that referenced this pull request Jan 17, 2020
Blank lines in backtick code block on blockquote should be kept.
But `backtick_code_block.js` removes them.
This patch fixes this behavior.
This bug is introduced by the PR hexojs#3765
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
v4.0.0
  
Done
Development

Successfully merging this pull request may close these issues.

The filter backtick_code_block makes markdown broken.
4 participants