diff --git a/doc/parser/kramdown.page b/doc/parser/kramdown.page index a851628f..3dd4e9f2 100644 --- a/doc/parser/kramdown.page +++ b/doc/parser/kramdown.page @@ -28,7 +28,7 @@ option `html_to_native` to `true` to achieve this. The kramdown parser supports the following options: -{options: {items: [parse_block_html, parse_span_html, html_to_native]}} +{options: {items: [auto_dd_para, parse_block_html, parse_span_html, html_to_native]}} [PHP Markdown Extra]: http://michelf.com/projects/php-markdown/extra/ diff --git a/doc/syntax.page b/doc/syntax.page index e8477a59..bb2c2c63 100644 --- a/doc/syntax.page +++ b/doc/syntax.page @@ -732,13 +732,16 @@ paragraph otherwise: definition term : This definition will just be text because it would normally be a - paragraph and the there is no preceding blank line. + paragraph and there is no preceding blank line. > although the definition contains other block-level elements : This definition *will* be a paragraph since it is preceded by a blank line. +To avoid the resulting mix of inline and block elements, you can use the `:auto_dd_para` option to +mark the first paragraph as such if it is followed by more blocks belonging to the same definition. + The rules about having any block-level element as first element in a list item also apply to a definition. diff --git a/lib/kramdown/options.rb b/lib/kramdown/options.rb index cc58b0a7..6897d5c4 100644 --- a/lib/kramdown/options.rb +++ b/lib/kramdown/options.rb @@ -305,6 +305,25 @@ def self.simple_hash_validator(val, name) val end + define(:auto_dd_para, Boolean, false, < 1)) it.children.first.children.first.value << "\n" if it.children.size > 1 it.children.first.options[:transparent] = true end diff --git a/test/testcases/block/13_definition_list/auto_dd_para.html b/test/testcases/block/13_definition_list/auto_dd_para.html new file mode 100644 index 00000000..0257d5f7 --- /dev/null +++ b/test/testcases/block/13_definition_list/auto_dd_para.html @@ -0,0 +1,32 @@ +
+
item1
+
+

para-iff-auto

+ +

para

+
+
item2
+
+

para-iff-auto

+

para

+
+
item3
+
+

para

+
+
item4
+
inline
+
item5
+
+

para-iff-auto

+
+
item6
+
+

para

+
+
item7
+
inline
+
item9
+
inline
+
+ diff --git a/test/testcases/block/13_definition_list/auto_dd_para.options b/test/testcases/block/13_definition_list/auto_dd_para.options new file mode 100644 index 00000000..c900b0cc --- /dev/null +++ b/test/testcases/block/13_definition_list/auto_dd_para.options @@ -0,0 +1 @@ +:auto_dd_para: true diff --git a/test/testcases/block/13_definition_list/auto_dd_para.text b/test/testcases/block/13_definition_list/auto_dd_para.text new file mode 100644 index 00000000..62682573 --- /dev/null +++ b/test/testcases/block/13_definition_list/auto_dd_para.text @@ -0,0 +1,33 @@ +item1 +: para-iff-auto + + para + +item2 +: para-iff-auto + ^ + para + +item3 + +: para + +item4 +: inline + +item5 +: para-iff-auto + ^ + +item6 +: ^ + para + +item7 +: + inline + +item9 +: inline + +