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

使用html标签的时候换行会被认为是换行 #422

Closed
laoyang945 opened this issue Jan 7, 2014 · 8 comments
Closed

使用html标签的时候换行会被认为是换行 #422

laoyang945 opened this issue Jan 7, 2014 · 8 comments

Comments

@laoyang945
Copy link

比如写一个简单的表格
如果html标签之间有换行的话,hexo会先去处理这些换行,然后再处理html标签的内容,这会导致很大的一个空白。不知道算是bug还是系统无法避免的东西。解决的方式是把html全部放在一行就行

@tommy351
Copy link
Member

tommy351 commented Jan 9, 2014

It may be a bug of marked. I'm trying to fix it.

@larshanw
Copy link

@tommy351 这个确实存在,把html放在一行很丑...

tommy351 added a commit that referenced this issue Jan 11, 2014
@tommy351 tommy351 reopened this Jan 15, 2014
@winterland1989
Copy link

找到一个workaround:

首先marked.setOptions中保证 breaks: false, 关闭gfm下的断行输出:

marked.setOptions({
  gfm: true,
  pedantic: false,
  sanitize: false,
  tables: true,
  breaks: false,
  smartLists: true,
  smartypants: true,
  renderer: r,
  langPrefix: '',
  highlight: function(code, lang){
    return highlight(code, {lang: lang, gutter: false, wrap: false});
  }
});

然后再使用lexer:

module.exports = function(data, options){
  headingId = {};
  var tokens = marked.lexer(data.text, options); 
  return marked.parser(tokens)
};

两个同时使用才生效,没搞懂为啥直接改options没有用,应该是marked的bug吧。

@tommy351
Copy link
Member

@winterland1989 The main reason should be the breaks setting. It may be the bug of marked.

@Xuanwo
Copy link
Contributor

Xuanwo commented Aug 7, 2014

最新版本修复了没?要是修复了,就关了吧。

@tommy351 tommy351 closed this as completed Aug 7, 2014
@letshare
Copy link

letshare commented Sep 8, 2014

为什么我用2.8.3最新版本还是存在table前面很多空行的情况?

@ckjoker
Copy link

ckjoker commented Mar 2, 2015

the bug is still remained.

@tommy351 tommy351 removed the bug Something isn't working label Mar 2, 2015
@leesei
Copy link
Member

leesei commented Jul 17, 2015

Ref #1388

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants