aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MANUAL.txt10
-rw-r--r--src/Text/Pandoc/Options.hs2
-rw-r--r--src/Text/Pandoc/Readers/Markdown.hs8
-rw-r--r--tests/markdown-reader-more.native4
-rw-r--r--tests/markdown-reader-more.txt3
5 files changed, 26 insertions, 1 deletions
diff --git a/MANUAL.txt b/MANUAL.txt
index 784cd415b..f78c410b3 100644
--- a/MANUAL.txt
+++ b/MANUAL.txt
@@ -3063,6 +3063,16 @@ For example:
is to look at the image resolution and the dpi metadata embedded in
the image file.
+Spans
+-----
+
+#### Extension: `bracketed_spans` ####
+
+A bracketed sequence of inlines, as one would use to begin
+a link, will be treated as a span with attributes if it is
+followed immediately by attributes:
+
+ [This is *some text*]{.class key="val"}
Footnotes
---------
diff --git a/src/Text/Pandoc/Options.hs b/src/Text/Pandoc/Options.hs
index 4f73cd99e..73f7a2039 100644
--- a/src/Text/Pandoc/Options.hs
+++ b/src/Text/Pandoc/Options.hs
@@ -84,6 +84,7 @@ data Extension =
| Ext_markdown_in_html_blocks -- ^ Interpret as markdown inside HTML blocks
| Ext_native_divs -- ^ Use Div blocks for contents of <div> tags
| Ext_native_spans -- ^ Use Span inlines for contents of <span>
+ | Ext_bracketed_spans -- ^ Bracketed spans with attributes
| Ext_markdown_attribute -- ^ Interpret text inside HTML as markdown
-- iff container has attribute 'markdown'
| Ext_escaped_line_breaks -- ^ Treat a backslash at EOL as linebreak
@@ -145,6 +146,7 @@ pandocExtensions = Set.fromList
, Ext_markdown_in_html_blocks
, Ext_native_divs
, Ext_native_spans
+ , Ext_bracketed_spans
, Ext_escaped_line_breaks
, Ext_fancy_lists
, Ext_startnum
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs
index 9928500dc..2e95c518d 100644
--- a/src/Text/Pandoc/Readers/Markdown.hs
+++ b/src/Text/Pandoc/Readers/Markdown.hs
@@ -1482,6 +1482,7 @@ inline = choice [ whitespace
, strongOrEmph
, note
, cite
+ , bracketedSpan
, link
, image
, math
@@ -1750,6 +1751,13 @@ link = try $ do
setState $ st{ stateAllowLinks = True }
regLink B.linkWith lab <|> referenceLink B.linkWith (lab,raw)
+bracketedSpan :: MarkdownParser (F Inlines)
+bracketedSpan = try $ do
+ guardEnabled Ext_bracketed_spans
+ (lab,_) <- reference
+ attr <- attributes
+ return $ B.spanWith attr <$> lab
+
regLink :: (Attr -> String -> String -> Inlines -> Inlines)
-> F Inlines -> MarkdownParser (F Inlines)
regLink constructor lab = try $ do
diff --git a/tests/markdown-reader-more.native b/tests/markdown-reader-more.native
index c38ffe038..136996068 100644
--- a/tests/markdown-reader-more.native
+++ b/tests/markdown-reader-more.native
@@ -163,4 +163,6 @@ Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "Author",S
,Para [Link ("",[],[]) [Str "foo2"] ("","")]
,Header 2 ("wrapping-shouldnt-introduce-new-list-items",[],[]) [Str "Wrapping",Space,Str "shouldn\8217t",Space,Str "introduce",Space,Str "new",Space,Str "list",Space,Str "items"]
,BulletList
- [[Plain [Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "2015."]]]]
+ [[Plain [Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "2015."]]]
+,Header 2 ("bracketed-spans",[],[]) [Str "Bracketed",Space,Str "spans"]
+,Para [Span ("id",["class"],[("key","val")]) [Emph [Str "foo"],Space,Str "bar",Space,Str "baz",Space,Link ("",[],[]) [Str "link"] ("url","")]]]
diff --git a/tests/markdown-reader-more.txt b/tests/markdown-reader-more.txt
index 4906a2eea..f649270c6 100644
--- a/tests/markdown-reader-more.txt
+++ b/tests/markdown-reader-more.txt
@@ -287,3 +287,6 @@ bar
- blah blah blah blah blah blah blah blah blah blah blah blah blah blah 2015.
+## Bracketed spans
+
+[*foo* bar baz [link](url)]{.class #id key=val}