forked from carpentries/styles
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
... by using GFM (GitHub-flavored Markdown) parser (`kramdown-parser-gfm`) instead of the default one (`kramdown`). The default one fails to produce an AST (Abstract Syntax Tree) when there is no blank line before the line with the opening code fence. Related: - gettalong/kramdown#530 - Python-Markdown/markdown#807 Fixes: carpentries#543
- Loading branch information
1 parent
d021e1f
commit d371a1c
Showing
3 changed files
with
8 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
#!/usr/bin/env ruby | ||
# frozen_string_literal: true | ||
# frozen-string-literal: true | ||
|
||
# Use Kramdown parser to produce AST for Markdown document. | ||
|
||
require 'kramdown' | ||
require 'json' | ||
require "kramdown" | ||
require "kramdown-parser-gfm" | ||
require "json" | ||
|
||
markdown = $stdin.read | ||
doc = Kramdown::Document.new(markdown) | ||
markdown = STDIN.read() | ||
doc = Kramdown::Document.new(markdown, input: 'GFM', hard_wrap: false) | ||
tree = doc.to_hash_a_s_t | ||
puts JSON.pretty_generate(tree) |