Code Monkey home page Code Monkey logo

hexo-renderer-marked's Introduction

hexo-renderer-marked

Build Status NPM version Coverage Status NPM Dependencies

Add support for Markdown. This plugin uses marked as its render engine.

Important note on security

By default, this plugin contains a potential security issue: It is possible to inject Markdown containing Unsafe HTML that will not be sanitized

This issue might not affect you because you checked the content of the markdown before using this plugin, but it's still a risk

There are two solutions to avoid those issues:

  1. First solution is to enable option dompurify: true, which will sanitize the rendered HTML. The side effect of this solution is that it will break any tag plugin (aka {% codeblock %}). This explains why the safer option has not been enabled by default
  2. Second solution is to migrate to hexo-renderer-markdown-it which is safe by default and does not suffer from the same limitations

Installation

$ npm install hexo-renderer-marked --save
  • Hexo 4: >= 2.0
  • Hexo 3: >= 0.2
  • Hexo 2: 0.1.x

Options

You can configure this plugin in _config.yml.

marked:
  gfm: true
  pedantic: false
  breaks: true
  smartLists: true
  smartypants: true
  quotes: '“”‘’'
  modifyAnchors: 0
  anchorAlias: false
  autolink: true
  mangle: true
  sanitizeUrl: false
  dompurify: false
  headerIds: true
  lazyload: false
  figcaption: false
  prependRoot: true
  postAsset: false
  external_link:
    enable: false
    exclude: []
    nofollow: false
  disableNunjucks: false
  descriptionLists: true
  • gfm - Enables GitHub flavored markdown
  • pedantic - Conform to obscure parts of markdown.pl as much as possible. Don't fix any of the original markdown bugs or poor behavior.
  • breaks - Enable GFM line breaks. This option requires the gfm option to be true.
  • smartLists - Use smarter list behavior than the original markdown.
  • smartypants - Use "smart" typographic punctuation for things like quotes and dashes.
  • quotes - Defines the double and single quotes used for substituting regular quotes if smartypants is enabled.
    • Example: '«»“”'
      • "double" will be turned into «double»
      • 'single' will be turned into “single”
    • Both double and single quotes substitution must be specified, otherwise it will be silently ignored.
  • modifyAnchors - Transform the anchorIds into lower case (1) or upper case (2).
  • autolink - Enable autolink for URLs. E.g. https://hexo.io will become <a href="https://hexo.io">https://hexo.io</a>.
  • mangle - Escape autolinked email address with HTML character references.
    • This is to obscure email address from basic crawler used by spam bot, while still readable to web browsers.
  • sanitizeUrl - Remove URLs that start with javascript:, vbscript: and data:.
  • dompurify - Enable DOMPurify to be run on the rendered Markdown. See below for configuration
  • headerIds - Insert header id, e.g. <h1 id="value">text</h1>. Useful for inserting anchor link to each paragraph with a heading.
  • anchorAlias - Enables custom header id
    • Example: ## [foo](#bar), id will be set as "bar".
    • Requires headerIds to be enabled.
  • lazyload - Lazy loading images via loading="lazy" attribute.
  • figcaption - Append figcaption element after each image.
  • prependRoot - Prepend root value to (internal) image path.
    • Example _config.yml:
    root: /blog/
    • ![text](/path/to/image.jpg) becomes <img src="/blog/path/to/image.jpg" alt="text">
  • postAsset - Resolve post asset's image path to relative path and prepend root value when post_asset_folder is enabled.
    • "image.jpg" is located at "/2020/01/02/foo/image.jpg", which is a post asset of "/2020/01/02/foo/".
    • ![](image.jpg) becomes <img src="/2020/01/02/foo/image.jpg">
    • Requires prependRoot to be enabled.
  • external_link
    • enable - Open external links in a new tab.
    • exclude - Exclude hostname. Specify subdomain when applicable, including www.
      • Example: [foo](https://example.com) becomes <a href="https://example.com" target="_blank" rel="noopener">foo</a>
    • nofollow - Add rel="noopener external nofollow noreferrer" to all external links for security, privacy and SEO. Read more. This can be enabled regardless of external_link.enable
      • Example: [foo](https://example.com) becomes <a href="https://example.com" rel="noopener external nofollow noreferrer">foo</a>
  • disableNunjucks: If true, Nunjucks tags {{ }} or {% %} (usually used by tag plugins) will not be rendered.
  • descriptionLists: Enable support for description lists syntax.
    • Currently description lists syntax is not in neither CommonMark or GFM, hexo-renderer-marked only provides the option for backward compatibility.
    • By disabling the descriptionLists, markdown rendering performance will be improved by a lot.

For more options, see Marked. Due to the customizations implemented by this plugin, some of the Marked's options may not work as expected. Feel free to raise an issue to us for clarification.

Extras

Sanitize HTML with DOMPurify

DOMPurify can be enabled to sanitize the rendered HTML.

To enable it, pass an object containing the DOMPurify options:

dompurify: true

Or you can enable specific DOMPurify options (but according to DOMPurify authors, the default options are safe):

dompurify:
  FORBID_TAGS:
  - "style"

See https://github.com/cure53/DOMPurify#can-i-configure-dompurify for a full reference of available options

Definition/Description Lists

hexo-renderer-marked also implements description/definition lists using the same syntax as PHP Markdown Extra.

This Markdown:

Definition Term
:    This is the definition for the term

will generate this HTML:

<dl>
  <dt>Definition Term</dt>
  <dd>This is the definition for the term</dd>
</dl>

Note: There is currently a limitation in this implementation. If multiple definitions are provided, the rendered HTML will be incorrect.

For example, this Markdown:

Definition Term
:    Definition 1
:    Definition 2

will generate this HTML:

<dl>
  <dt>Definition Term<br>: Definition 1</dt>
  <dd>Definition 2</dd>
</dl>

If you've got ideas on how to support multiple definitions, please provide a pull request. We'd love to support it.

Extensibility

This plugin overrides some default behaviours of how marked plugin renders the markdown into html, to integrate with the Hexo ecosystem. It is possible to override this plugin too, without resorting to forking the whole thing.

For example, to override how heading like # heading text is rendered:

hexo.extend.filter.register('marked:renderer', function(renderer) {
  const { config } = this; // Skip this line if you don't need user config from _config.yml
  renderer.heading = function(text, level) {
    // Default behaviour
    // return `<h${level}>${text}</h${level}>`;
    // outputs <h1>heading text</h1>

    // If you want to insert custom class name
    return `<h${level} class="headerlink">${text}</h${level}>`;
    // outputs <h1 class="headerlink">heading text</h1>
  }
})

Save the file in "scripts/" folder and run Hexo as usual.

Notice renderer.heading = function (text, level) { corresponds to this line. Refer to renderer.js on how this plugin overrides the default methods. For other methods not covered by this plugin, refer to marked's documentation.

Tokenizer

It is also possible to customize the tokenizer.

const { escapeHTML: escape } = require('hexo-util');

// https://github.com/markedjs/marked/blob/b6773fca412c339e0cedd56b63f9fa1583cfd372/src/Lexer.js#L8-L24
// Replace dashes only
const smartypants = (str) => {
  return str
    // em-dashes
    .replace(/---/g, '\u2014')
    // en-dashes
    .replace(/--/g, '\u2013')
};

hexo.extend.filter.register('marked:tokenizer', function(tokenizer) {
  const { smartypants: isSmarty } = this.config.marked;
  tokenizer.inlineText = function(src, inRawBlock) {
    const { rules } = this;

    // https://github.com/markedjs/marked/blob/b6773fca412c339e0cedd56b63f9fa1583cfd372/src/Tokenizer.js#L643-L658
    const cap = rules.inline.text.exec(src);
    if (cap) {
      let text;
      if (inRawBlock) {
        text = cap[0];
      } else {
        text = escape(isSmarty ? smartypants(cap[0]) : cap[0]);
      }
      return {
        // `type` value is a corresponding renderer method
        // https://marked.js.org/using_pro#inline-level-renderer-methods
        type: 'text',
        raw: cap[0],
        text
      };
    }
  }
});

Extensions

It is also possible to customize the extensions. For example, use KaTeX to render block-level math:

const katex = require('katex');

hexo.extend.filter.register('marked:extensions', function(extensions) {
  // Info: `extensions` is an array.
  extensions.push({
    name: 'blockMath',
    level: 'block',
    tokenizer(src) {
      const cap = /^\s{0,3}\$\$((?:[^\n]|\n[^\n])+?)\n{0,1}\$\$/.exec(src);

      if (cap !== null) {
        return {
          type: 'blockMath',
          raw: cap[0],
          math: cap[1]
        };
      }

      return undefined;
    },
    renderer(token) {
      return `<p>${katex.renderToString(token.math, {displayMode: true})}</p>\n`;
    }
  });
});

You may also get access to marked.use function. For example to use the marked-alert extention wich also provides a walkTokens functions:

const markedAlert = require('marked-alert');

hexo.extend.filter.register('marked:use', function (markedUse) {
  markedUse(markedAlert());
});

hexo-renderer-marked's People

Contributors

0xflotus avatar cgmartin avatar crycode-de avatar curbengh avatar dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar eumeryx avatar hisaac avatar jiangtj avatar jlhwung avatar ksky521 avatar liuhongjiang avatar mathiasbynens avatar muhac avatar noahdragon avatar pashokus avatar rstoenescu avatar segayuu avatar stevenjoezhang avatar sukkaw avatar tcrowe avatar tomap avatar tommy351 avatar vhf avatar weyusi avatar yoshinorin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hexo-renderer-marked's Issues

bug ‘ '

every ' is rendered as , that's really annoying.

for example, in this page

Expected behavior:

selection_002

Actual behavior:

selection_001

HELP ME PLEASE! thx 😭

HTML TABLE 上方有大块的空白

当使用HTML table 时,在table上方会有很多 <br> 出现。导致表格上方有大块的空白

<table>
  <thead>
    <tr>
      <th>产品</th>
      <th>发送方式</th>
      <th>刷盘策略</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>KAFKA</td>
      <td>同步发送</td>
      <td>异步刷盘</td>  
    </tr>
  </tbody>
</table>

image

In a github table, an inline code block that contains a | adds columns - it should not

When a pipe is in a table, you can escape it with a \ on github markdown. In hexo-renderer-marked this does not work. As seen below, it works as intended here. But if you copy paste that table into hexo-renderer-marked row3 cell2 will behave just like row2 cell2 without an escape.

|col1 |col2 |
|-----|-----|
|row1|`cell2`|
|row2|`this cell2 has no | escape on the pipe`|
|row3|`this cell2 has an \| escape on the pipe`|
col1 col2
row1 cell2
row2 `this cell2 has no
row3 this cell2 has an | escape on the pipe

WordPress migration

$ hexo migrate wordpress https://exports.files.wordpress.com/2018/03/longliveandprosperblog-wordpress-com-2018-03-03-12_25_43-enw6dmht0rtyrxsw6ge4gx4axxhzrbam.zip
INFO  Analyzing https://exports.files.wordpress.com/2018/03/longliveandprosperblog-wordpress-com-2018-03-03-12_25_43-enw6dmht0rtyrxsw6ge4gx4axxhzrbam.zip...
FATAL Something's wrong. Maybe you can find the solution here: http://hexo.io/docs/troubleshooting.html
Error: Non-whitespace before first tag.
Line: 0
Column: 1
Char: P
    at error (/home/wm/Playground/BuildABlogSite/node_modules/xml2js/node_modules/sax/lib/sax.js:642:8)
    at strictFail (/home/wm/Playground/BuildABlogSite/node_modules/xml2js/node_modules/sax/lib/sax.js:662:22)
    at Object.write (/home/wm/Playground/BuildABlogSite/node_modules/xml2js/node_modules/sax/lib/sax.js:934:11)
    at Parser.exports.Parser.Parser.parseString (/home/wm/Playground/BuildABlogSite/node_modules/xml2js/lib/xml2js.js:398:31)
    at Parser.parseString (/home/wm/Playground/BuildABlogSite/node_modules/xml2js/lib/xml2js.js:6:61)
    at Object.exports.parseString (/home/wm/Playground/BuildABlogSite/node_modules/xml2js/lib/xml2js.js:428:19)
    at async.waterfall.count (/home/wm/Playground/BuildABlogSite/node_modules/hexo-migrator-wordpress/index.js:43:14)
    at fn (/home/wm/Playground/BuildABlogSite/node_modules/hexo-migrator-wordpress/node_modules/async/lib/async.js:638:34)
    at Immediate.<anonymous> (/home/wm/Playground/BuildABlogSite/node_modules/hexo-migrator-wordpress/node_modules/async/lib/async.js:554:34)
    at runCallback (timers.js:672:20)
    at tryOnImmediate (timers.js:645:5)
    at processImmediate [as _immediateCallback] (timers.js:617:5)

Options to disable automatic header #ids

When we write in markdown file something like this:
### Heading

By default it will parse to:
<h3 id="Heading"><a href="#Heading" class="headerlink" title="Heading"></a>Heading</h3>

Marked parser has a feature to disable the automatic header ids in its advanced options, just set the "headerIds" to false and its ok.
screenshot_1

So do we have something like this ?

marked:
  headerIds: false

Or what i need to do to render normal view Headings, like <h3>Heading</h3>, without ids, classes or inner links

how to show post title correctly when html files are used as posts

Steps to reproduce the behavior

  1. I have a html file
  2. move the html file to source/_posts folder
  3. run hexo s

If we put html files in _posts folder, hexo will automatically combine html files and the theme. The content of the html files is now the content of the new posts.

On the homepage, the titles of the posts generated are "Untitled". When the default landscape theme is active, the "recent posts" on the sidebar show the same result. This is not what I wanted. I hope that the titles of the posts are those of original html files. In addition, how to set excerpt, tags, categories, and additional yaml varaibles for this type of posts? How can I achieve this?

Adding video element

First off, I'm pretty new to the entire Hexo framework and its components.

Having gotten that out of the way, I've been struggling for the past couple of days trying to create a script/tag to generate a styled <video> element. The video files are hosted as part of my blog and thus, I don't want to make use of the youtube tag plugin.

Before I got to styling the element, I decided to try and write up a basic tag plugin to insert a plain <video> object.

So far, my post contains the following:

...
...
{% video %} {% asset_path test.mp4 %} {% endvideo %}

# Watch videos from any website
...

My script is defined as follows:

hexo.extend.tag.register('video', (args, content) => {
  return `<video> <source src="${content}" type="video/mp4"> </video>`
}, {ends: true})

The moment I run my code however, the text following the video, '# Watch videos from any website', is no longer parsed properly.

How can I properly insert a video element?

I'm not seeing gfm table

Hi,

I installed this and added to the marked options to my _config.yml, but it's not drawing a table. How can I tell if it's rendering with marked?

Effective way to render ~~blah~~ as <s>blah</s> instead of <del>blah</del>

Hello there,

I use [email protected] with [email protected] and I discovered that gfm syntax actually replaces ~~ with <del> HTML tag instead of <s>.

Today I discovered (thanks @nhoizey) that browsers/clients do not need to render <del> (considered as document edit) whereas it is mandatory for <s> (considered as a presentation feature).

The HTML Deleted Text Element () represents a range of text that has been deleted from a document. This element is often (but need not be) rendered with strike-through text.

Some RSS readers (like Readkit.app) suppress the display of <del> making the experience a bit less comfortable.

GFM line breaks doesn't work

when using [email protected],
and hexo config prints

...
marked:
   { gfm: true,
     pedantic: false,
     sanitize: false,
     tables: true,
     breaks: true,
     smartLists: true,
     smartypants: true },
...
aaaa
bbbb

will result as

aaaa
bbbb

instead of the way GFM line breaks style supposed.

How to show specific line numbers of the code block manually?

Expected Behavior

I want to specify the line numbers by myself. I'm currently work on a solution of a book. Since I want to correspond to the book's style, I hope I can start the line number "1" from the second line, not the first line.

In the hexo-theme-doc, It'll show something like this(regardless the syntax.)

  1  func(a, b)     
  2      A()        
  3      return B      

I hope something like this:

     func(a, b)     
  1      A()        
  2      return B   

Or sometimes I want it show from a specific line number like:

  8  func()
  9      A()        
 10      return B      

Is it possible to change this? Thanks a lot!!

Specifications

  • NodeJS Version: 8.9.4
  • NPM Version: 5.6.0
  • OS: macOS High Sierra version 10.13.3
  • Hexo Version: 3.5.0

少生成一个空格

System:mac
hexo version:3.2.0
hexo-renderer-marked:0.2.10

raw input

## Title

### SG

|spec|comp|class|status|info|update|
|----|---|------|----|----|----|
|a|a|a|a|||
|a|a|a|a|||

output

<h2 id="Title"><a href="#Title" class="headerlink" title="Title"></a>Title</h2><h3 id="SG"><a href="#SG" class="headerlink" title="SG"></a>SG</h3><table>
<thead>
<tr>
<th>spec</th>
<th>comp</th>
<th>class</th>
<th>status</th>
<th>info</th>
<th>update</th>
</tr>
</thead>
<tbody>
<tr>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
<td></td>
<td></td>
</tr>
<tr>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
<td></td>
</tr>
</tbody>
</table>

The last tr is short of a td.

qq20171220-235451

我在代码中进行断点调试,截图如下:

qq20171220-235853

qq20171221-000344

text less than 3 chars is not italicized

It seems to be fixed in marked 0.4.0 (markedjs/marked#1181).

You can reproduce it by adding following code to hexo-renderer-marked/test/index.js.

it('should italicize 2 chars text correctly', function() {
  r({text: '*AND*'}).should.eql('<p><em>AND</em></p>\n');  // => PASS
  r({text: '_AND_'}).should.eql('<p><em>AND</em></p>\n');  // => PASS
  r({text: '*OK*'}).should.eql('<p><em>OK</em></p>\n');    // => PASS
  r({text: '_OK_'}).should.eql('<p><em>OK</em></p>\n');    // => FAILED
});

unable to generate h1 tag with iframe?

I have used markdown heading style with iframe, it looks like the h1 HTML tags cannot be generated from the markdown.

Source:
markdown heading style

The generated HTML looks like:
generated HTML

markdown 渲染 ``` 时容易出错

最近写博客时遇到的一个问题:

当我在博客中写下如下内容时,

test

test2

我希望的效果是这样的,

test

test

然而实际效果却是结构错乱,你可以在hexo中试着渲染一下试试。

最后我花了很长很长很长很长时间终于发现问题了:
原来我在第二个 ``` 后面多加了一个空格。。当时我的内心是崩溃的。

相信有不少人可能遇到和我同样的问题,建议修复一下~

原issue地址:hexojs/hexo#1684 (comment)

Considering update marked version?

It seems marked has updated to 0.5.0 and this plugin still keeps 0.3.x, is there anyone maintaining that can update marked version to the newest? The version now cannot links with parentheses like this:

[Something](http://something.com/exam\(ple\).html)

As you see even you escaped ), this version of marked still doesn't work properly, newer version fixed it.

Pipes `|` not rendering correctly in cells with Marked renderer

Environment Info

Node version(node -v)

v7.4.0

Plugin version(npm ls --depth 0)

BUG

Description : pipes inside inline code block inside an array don't display correctly.

Markdown code:

`||`

a     | b
---   | ---
`||`  | `pipe pipe`

Bugous behaviour:

Espected behaviour:

I may also open this bug into marked and hexo-renderer-marked repositories. I also tried with a fresh hexo install and the behaviour is the same.

首页文章摘要显示代码行号Bug

当我站点设置中开启代码行号:

highlight:
  enable: true
  line_number: true

并在主题设置中设置自动摘要:

auto_excerpt:
  enable: true
  length: 150

那么要出现一个问题,在首页生成的文件摘要会出现摘要显示为一串数字,应该是代码行号:

发表于 2017-03-17 | 分类于 JAVA
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051import java.util.*;class Fruit { public String t ...
阅读全文 »

iissnan/hexo-theme-next#1591

Import (and render) one markdown file into another

Is it possible to import (and render) one markdown file into another?
I have a markdown formatted table that i want to include on multiple pages. This is content related (not theme related) but i couldnt find anything in the documentation that allows for this.

title: "Fancy Title"
date: 2015-08-01 02:00:00

---

Some fancy text here about something

{% markdown_partial /path/to/file %}

Some other text here..

bug: it generates many <br> before <table>

1. markdown file

## table
<table>
         <thead>
                 <tr>
                         <th>#</th>
                         <th>Name</th>
                         <th>Street</th>
                 </tr>
         </thead>
         <tbody>
                 <tr>
                         <td>1</td>
                         <td>Anna Awesome</td>
                         <td>Broome Street</td>
                 </tr>
                 <tr>
                         <td>2</td>
                         <td>Debbie Dallas</td>
                         <td>Houston Street</td>
                 </tr>
                 <tr>
                         <td>3</td>
                         <td>John Doe</td>
                         <td>Madison Street</td>
                 </tr>
         </tbody>
</table>

2. github render

table

# Name Street
1 Anna Awesome Broome Street
2 Debbie Dallas Houston Street
3 John Doe Madison Street

3. hexo render

it generates many <br> before <table>

table


























# Name Street
1 Anna Awesome Broome Street
2 Debbie Dallas Houston Street
3 John Doe Madison Street

4. bug

I am not sure whether the bug comes from markedjs or hexo-renderer-marked or or Hexo issue. @NoahDragon

Specifications

Not working in the Hexo 3 beta

The renderer fails on the new beta version.

Error

TypeError: Cannot read property 'highlight' of undefined
    at C:\gh\hexotest\node_modules\hexo-renderer-marked\index.js:4:19
    at C:\Users\celso_000\AppData\Roaming\npm\node_modules\hexo\lib\hexo\index.js:210:12
    at tryCatch1 (C:\Users\celso_000\AppData\Roaming\npm\node_modules\hexo\node_modules\bluebird\js\main\util.js:29:21)
    at Promise._settlePromiseFromHandler (C:\Users\celso_000\AppData\Roaming\npm\node_modules\hexo\node_modules\bluebird
\js\main\promise.js:588:13)
    at Promise._settlePromiseAt (C:\Users\celso_000\AppData\Roaming\npm\node_modules\hexo\node_modules\bluebird\js\main\
promise.js:756:18)
    at Promise._settlePromises (C:\Users\celso_000\AppData\Roaming\npm\node_modules\hexo\node_modules\bluebird\js\main\p
romise.js:873:14)
    at Async._drainQueue (C:\Users\celso_000\AppData\Roaming\npm\node_modules\hexo\node_modules\bluebird\js\main\async.j
s:78:16)
    at Async._drainQueues (C:\Users\celso_000\AppData\Roaming\npm\node_modules\hexo\node_modules\bluebird\js\main\async.
js:88:10)
    at Async.drainQueues (C:\Users\celso_000\AppData\Roaming\npm\node_modules\hexo\node_modules\bluebird\js\main\async.j
s:13:14)
    at process._tickCallback (node.js:442:13)

Version

$ hexo version

hexo: 3.0.0-beta.2
os: Windows_NT 6.2.9200 win32 x64
http_parser: 1.0
node: 0.10.35
v8: 3.14.5.9
ares: 1.9.0-DEV
uv: 0.10.30
zlib: 1.2.8
modules: 11
openssl: 1.0.1j

Math and quotation mark rendering default

"hexo": { "version": "3.3.8" }, "hexo-renderer-marked": "^0.3.0", newest Next theme

I have trouble when rendering math and quotation marks. For example,
\sigma_{x}^2 \sigma_{y}^2 will have, after rendered by markdown engine, an italic effect for all characters right after {x}, so that mathjax rendering engine cannot recognize the original formula.

The same problem for \{, \[, \\ and etc.

The problem for quotation marks is that they always look like in Chinese style, i.e., rounded and succeeded by a white space, just like this:

P.S. I use the default mathjax support for next theme.

Wrong indent

The paragraph starting with "這一項是最令我困擾的" would indent one more level in Hexo, which is wrong. Can be fixed if pedantic is true.

  1. 程式碼很醜:我的程式碼可以跑,但是:

    • 我喜歡為變數取名叫 x、flag、str、arr 等等。
    • 我絕大多數的程式碼都集中在一個很長很長的函式裡。
    • 沒有縮排。
    • 沒有一致的風格和規則。
    • 到處都是全域變數。

    這一項是最令我困擾的。也不是說程式寫得不好啦,這裡面還是有可能會有超猛的程式碼。但我打個比方,如果一串鑽石項鍊掛在像酷斯拉那麼大的超巨型噁心怪蟲的屍體上被埋葬於地底,就再也不會有人找到它了。就算被找到,也不會有人想要清理它甚或戴上它。

  2. 短線投機客:他會不斷地寫出程式給你,但是不會嘗試深入瞭解問題,對程式應用領域的背景知識也全無興趣。

    給他一些工作,他就算加班也會使命必達地交給你一個會動的程式。但也僅止於此。有時候開發人員具備一些自私的心態,促使他不只關心截止日期,也想從處理的事物中學到東西是很重要的。

how to contribute code?

I change a little bit code in /lib/renderer.js whose content is

text = text.replace(/^\s*(<p>\s*)?\[ \]\s*/i, '<input type="checkbox" disabled="disabled"></input> ').replace(/^\s*(<p>\s*)?\[x\]\s*/i, '<input type="checkbox" checked="checked" disabled="disabled"></input> ');

Because I want to support ToDo List, when visitor can not do anything on the checkbox.

Code block not rendering correctly - adds additional lines

I have a Hexo blog I am using with Bulma that is built on Flexbox. I render the post content like this:

    <div class='container top-offset-30'>
        <div class='columns is-mobile'>
            <div class='column is-8 is-offset-2'>
                <%- post.content %>
            </div>
        </div>
    </div>

Here is the markdown file:

In my previous post on meteor we did not use controllers, now we do. The controller looks like this:

` ``` 
TodosController = RouteController.extend({
  subscriptions: function () {
    this.subscribe('todoDetail', this.params._id);
  },

  // set data context for controller
  data: function () {
    return Todos.findOne({_id: this.params._id});
  },

  detail: function(){
    this.render('TodosDetail', {});
  },

  edit: function(){
    // reactive state variable saying we're in edit mode
    this.state.set('isEditing', true);
    
    this.render('TodosDetail');
  }
});
` ```

(There are only three backticks in my markdown file but wanted it render right in github issue)

The issue is that when it displays in the browser the code block hangs past the end like so:

screen shot 2017-08-10 at 9 58 29 am

Are there any ideas on how to fix this? Thank you

A problem when writing a code block in the list

I verified the code here(hexo#2620 ), but the code below could not be displayed well. Also, in this case is difficult to describe accurately.

If you put a blank line break after the code block, it seems that it can not render well.
Perhaps it is a bug in hexo-renderer-marked.

This is a very rare use, but it may be better to fix it.

block

Code that goes well

some text here

1. step 1

    ```
    sudo dpkg -i chrome.deb
    sudo apt-get install -f
    ```

2. step 2

    ```
    sudo apt-get install gdebi
    ```
    install with gdebi

Code that can not be displayed as expected

some text here

1. step 1

    ```
    sudo dpkg -i chrome.deb
    sudo apt-get install -f
    ```

2. step 2

    ```
    sudo apt-get install gdebi
    ```
    
    install with gdebi

TypeError: this.relative_url is not a function

This issue was originally raised on the Hexo repo (hexojs/hexo#1680), but it doesn't appear to be their fault. The issue was created in 8e3dc69 in lines 37-46 of lib/renderer.js. By calling url_for with the given ctx as the context, it is breaking the call to this.relative_url in Hexo's code: https://github.com/hexojs/hexo/blob/master/lib/plugins/helper/url_for.js#L28

I don't really know what the solution is, but this clearly isn't the correct context to use.

angle brackets < and > not escaped properly in non-HTML code blocks

npm install <plugin name> --save-dev

currently renders in the browser as:

<pre class=" language-shell">
  <code class="language-shell">
    npm install 
    <plugin name=""> 
      --save-dev
    </plugin>
  </code>
</pre>

This code should replace the angle brackets < and > with HTML escaped chars &lt; and &gt; when it is used within a code blocks that are explicitly not HTML code blocks

The current workaround is replacing the angle brackets yourself with the escaped chars like so:

npm install &lt;plugin name&gt; --save-dev

This renders the properly formed HTML:

<pre class=" language-shell">
  <code class="language-shell">
    npm install &lt;plugin name&gt; --save-dev
  </code>
</pre>

每个换行的位置会加一个空格

配置

marked:
  gfm: true
  pedantic: false
  sanitize: false
  tables: true
  breaks: false
  smartLists: true
  smartypants: true
  modifyAnchors: ''
  autolink: true

比如以下的换行
image

结果如下多了一个空格
image

image path not correct with new version 0.2.8

i have post_asset_folder: true in my _config.yml and using image like this ![](image_name.jpg). and the result with be <img src="image_name.jpg">.

the image path won't work with new version of [email protected].

there's an additional / before the generated path, so what i get is <img src="/image_name.jpg">

锚点链接有多余空格

如果有如下代码

- [测试1](#测试1)
- [测试2](#测试2)
- [测试3](#测试3)

则在渲染出来的锚点链接中的#号后面会多出一个空格,如url/to/article/# 测试1,英文锚点不会有此现象。

my hexo-renderer-marked seems to not work

my hexo version is 3.8.0.

I install this plugin with

$ npm install hexo-renderer-marked --save

and put the configuration in my _config.yml in the root directory of my hexo project. but it not work, somebody can help? thanks.

Adds a config to make this renderer does not parse text in '$$' and '$'

Now most of the blogs uses hexo-math or other some math plugins to render LaTeX formulas.
But there is a probem: if the formula contains two _, this renderer will parse it into tags, and the formula is broken.
So could we add a config to make this renderer does not parse text in '$$' and '$'? Because usally they are the characters surrounding LaTeX formulas.

Adds a config entry to make this renderer does not parse text in '$$' and '$'

Now most of the blogs uses hexo-math or other some math plugins to render LaTeX formulas.
But there is a probem: if the formula contains two _, this renderer will parse it into <em> tags, and the formula is broken.
So could we add a config to make this renderer does not parse text in $$ and $? Because usally they are the characters surrounding LaTeX formulas.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.