Open ccoupe opened 7 years ago
Kramdown source code reveals it's options. Something along options: { :gfm_quirks }
.
Something along options: { :gfm_quirks }
Grrr. the more correct fix that passes kramdown checks but appears to do nothing useful is
render_doc = Kramdown::Document.new(File.read(File.join(dir, file)),
{ :syntax_highlighter => "rouge",
:syntax_highlighter_opts => { css_class: false, line_numbers: false, inline_theme: "github" },
cfg: cfg, chapter: sect_nm, input: cfg['input_format'],
gfm_quirks: ['hard_wrap']
}
It's going to be much easier to fix the source md than figure out kramdown's odd logic. I'm going to repeat myself and little more strongly "I am not going to become a kramdown expert" Life is short and I've got enough to do. You've got a real proof of concept. You asked for a list of issues. You got that. Fix one of them.
Could you provide a simple test case that cause the problem? I need a test case to work on.
The https://github.com/Shoes3/shoes3/wiki/8.0-New-Widgets file in the wiki is small and has several wrapping issues.
Have you tried :wrap => word ? Also, would you post a screenshot of the current defective rendering?
I didn't :wrap ==> word was an option. Highly like that there are two hard line endings in the source.
Now the problem is very clear. Thanks.
The :wrap option is in the manual. We did have a lengthy conversation about it when it came to Shoes Console. The line endings are not problematic (see screenshot below with display hidden characters turned on in an editor). There are two noticeable problems: 1) lines are cut off, 2) we may have to ignore some end of lines. The Markdown file itself is fine.
Kramdown generates multiple para and call convert_br on each end lines. It should ideally group together lines of a paragraph into one para.
There is the gkt3 wrap word option. Kramdown however, https://kramdown.gettalong.org/options.html as some odd logic involved with hardwrap - the default is true but there doesn't appear to be anyway to turn if off. gfm_quirks: ['hard_wrap']
is the only thing that passes it's parser.
Are you using options correctly? According to this test case, it should be :hard_wrap => false
(or true). Take a loot at Paragraph End Disable Option: gfm_quirks: 'paragraph_end'
.
hard_wrap: false
is working just fine!
doc = Kramdown::Document.new(File.read("codespan_block.md"),
{input: 'GFM', hard_wrap: false}).to_shoes
That is better but still not what happens with github/html
The good news is the generated code is correct. A simple gsub
in convert_text seems to do the trick.
def convert_text(el)
%{para("#{el.value.gsub("\n", ' ')}", :margin_left => 0, :margin_right => 0)}
end
Excellent! I'm tempted to close the issue.
Excellent! I'm tempted to close the issue.
Shall we close this issue? There are few others might also be deserving to be closed.
Oddly enough, there isn't a lot of google help on how to do that. (other than read and grok the entire kramdown source code). I don't want to be a kramdown internals guru! This doesn't work: