Changed nomenclature, delimited -> fenced code blocks.

This commit is contained in:
John MacFarlane 2012-08-21 19:21:51 -07:00
parent 7b34dd8dd1
commit b985d33406
4 changed files with 15 additions and 15 deletions

12
README
View file

@ -22,7 +22,7 @@ slide shows), [ConTeXt], [RTF], [DocBook XML], [OpenDocument XML],
[PDF] output on systems where LaTeX is installed.
Pandoc's enhanced version of markdown includes syntax for footnotes,
tables, flexible ordered lists, definition lists, delimited code blocks,
tables, flexible ordered lists, definition lists, fenced code blocks,
superscript, subscript, strikeout, title blocks, automatic tables of
contents, embedded LaTeX math, citations, and markdown inside HTML block
elements. (These enhancements, described below under
@ -971,12 +971,12 @@ of the verbatim text, and is removed in the output.
Note: blank lines in the verbatim text need not begin with four spaces.
### Delimited code blocks ###
### Fenced code blocks ###
**Extension: `delimited_code_blocks`**
**Extension: `fenced_code_blocks`**
In addition to standard indented code blocks, Pandoc supports
*delimited* code blocks. These begin with a row of three or more
*fenced* code blocks. These begin with a row of three or more
tildes (`~`) or backticks (`` ` ``) and end with a row of tildes or
backticks that must be at least as long as the starting row. Everything
between these lines is treated as code. No indentation is necessary:
@ -987,7 +987,7 @@ between these lines is treated as code. No indentation is necessary:
}
~~~~~~~
Like regular code blocks, delimited code blocks must be separated
Like regular code blocks, fenced code blocks must be separated
from surrounding text by blank lines.
If the code itself contains a row of tildes or backticks, just use a longer
@ -1745,7 +1745,7 @@ work in verbatim contexts:
**Extension: `inline_code_attributes`**
Attributes can be attached to verbatim text, just as with
[delimited code blocks](#delimited-code-blocks):
[fenced code blocks](#fenced-code-blocks):
`<$>`{.haskell}

View file

@ -64,7 +64,7 @@ data Extension =
| Ext_tex_math_single_backslash -- ^ TeX math btw \(..\) \[..\]
| Ext_tex_math_double_backslash -- ^ TeX math btw \\(..\\) \\[..\\]
| Ext_latex_macros -- ^ Parse LaTeX macro definitions (for math only)
| Ext_delimited_code_blocks -- ^ Parse delimited code blocks
| Ext_fenced_code_blocks -- ^ Parse fenced code blocks
| Ext_inline_code_attributes -- ^ Allow attributes on inline code
| Ext_markdown_in_html_blocks -- ^ Interpret as markdown inside HTML blocks
| Ext_markdown_attribute -- ^ Interpret text inside HTML as markdown
@ -104,7 +104,7 @@ pandocExtensions = Set.fromList
, Ext_raw_html
, Ext_tex_math_dollars
, Ext_latex_macros
, Ext_delimited_code_blocks
, Ext_fenced_code_blocks
, Ext_inline_code_attributes
, Ext_markdown_in_html_blocks
, Ext_escaped_line_breaks

View file

@ -306,7 +306,7 @@ parseBlocks :: Parser [Char] ParserState (F Blocks)
parseBlocks = mconcat <$> manyTill block eof
block :: Parser [Char] ParserState (F Blocks)
block = choice [ codeBlockDelimited
block = choice [ codeBlockFenced
, guardEnabled Ext_latex_macros *> (mempty <$ macro)
, header
, rawTeXBlock
@ -435,9 +435,9 @@ keyValAttr = try $ do
<|> many nonspaceChar
return ("",[],[(key,val)])
codeBlockDelimited :: Parser [Char] ParserState (F Blocks)
codeBlockDelimited = try $ do
guardEnabled Ext_delimited_code_blocks
codeBlockFenced :: Parser [Char] ParserState (F Blocks)
codeBlockFenced = try $ do
guardEnabled Ext_fenced_code_blocks
(size, attr, c) <- blockDelimiter (\c -> c == '~' || c == '`') Nothing
contents <- manyTill anyLine (blockDelimiter (== c) (Just size))
blanklines

View file

@ -292,8 +292,8 @@ blockToMarkdown opts (CodeBlock (_,classes,_) str)
isEnabled Ext_literate_haskell opts =
return $ prefixed "> " (text str) <> blankline
blockToMarkdown opts (CodeBlock attribs str) = return $
if isEnabled Ext_delimited_code_blocks opts && attribs /= nullAttr
then -- use delimited code block
if isEnabled Ext_fenced_code_blocks opts && attribs /= nullAttr
then -- use fenced code block
(tildes <> space <> attrs <> cr <> text str <>
cr <> tildes) <> blankline
else nest (writerTabStop opts) (text str) <> blankline
@ -468,7 +468,7 @@ blockListToMarkdown opts blocks =
-- insert comment between list and indented code block, or the
-- code block will be treated as a list continuation paragraph
where fixBlocks (b : CodeBlock attr x : rest)
| (not (isEnabled Ext_delimited_code_blocks opts) || attr == nullAttr)
| (not (isEnabled Ext_fenced_code_blocks opts) || attr == nullAttr)
&& isListBlock b =
b : RawBlock "html" "<!-- -->\n" : CodeBlock attr x :
fixBlocks rest