diff --git a/README.md b/README.md index 2719bdd..726c1cb 100644 --- a/README.md +++ b/README.md @@ -168,10 +168,10 @@ content to include. are rewritten to work correctly in their new location. Possible values are `true` and `false`. - # - **comments** (_true_): When this option is enabled (default), the content to - include is wrapped by `` and `` - comments which help to identify that the content has been included. Possible - values are `true` and `false`. + **comments** (_false_): When this option is enabled, the content to include + is wrapped by `` and `` comments + which help to identify that the content has been included. Possible values + are `true` and `false`. - # **heading-offset** (0): Increases or decreases the Markdown headings depth by this number. Only supports number sign (`#`) heading syntax. Accepts @@ -193,7 +193,7 @@ content to include. start='' end='' rewrite-relative-urls=false - comments=false + comments=true %} ``` diff --git a/examples/custom-tags/docs/index.md b/examples/custom-tags/docs/index.md index fe9025f..23d57bf 100644 --- a/examples/custom-tags/docs/index.md +++ b/examples/custom-tags/docs/index.md @@ -2,7 +2,7 @@ |> include-markdown "./included.md" -comments=false +comments=true <| |> include './included.md' <| diff --git a/examples/start-end-not-found-warnings/docs/index.md b/examples/start-end-not-found-warnings/docs/index.md index f28f751..e459be8 100644 --- a/examples/start-end-not-found-warnings/docs/index.md +++ b/examples/start-end-not-found-warnings/docs/index.md @@ -4,11 +4,11 @@ include-markdown "./included.md" start="<--start-->" end="<--end-->" - comments=false %} {% include './included.md' start="<--start-->" end="<--end-->" + comments=true %} diff --git a/examples/table-as-list-item/docs/index.md b/examples/table-as-list-item/docs/index.md index f76c54d..44959c5 100644 --- a/examples/table-as-list-item/docs/index.md +++ b/examples/table-as-list-item/docs/index.md @@ -5,7 +5,6 @@ {% include-markdown "./table.md" - comments=false %} 1. Another list entry diff --git a/locale/es/README.md b/locale/es/README.md index ce00043..b167809 100644 --- a/locale/es/README.md +++ b/locale/es/README.md @@ -159,8 +159,8 @@ imágenes Markdown en el contenido que están definidas mediante una URL relativ son rescritos para funcionar correctamente en su nueva localización. Los valores posibles son `true` y `false`. - # -**comments** (*true*): Cuando esta opción está habilitada (por defecto), el -contenido a incluir es envuelto por comentarios `` y +**comments** (*false*): Cuando esta opción está habilitada, el contenido a +incluir es envuelto por comentarios `` y `` que ayudan a identificar que el contenido ha sido incluido. Los valores posibles son `true` y `false`. - # **comments** (*true*): When this option is enabled" -" (default), the content to include is wrapped by `` " -"and `` comments which help to identify that the content " -"has been included. Possible values are `true` and `false`." +"markdown_comments\"># **comments** (*false*): When this option is " +"enabled, the content to include is wrapped by `` and " +"`` comments which help to identify that the content has " +"been included. Possible values are `true` and `false`." msgstr "" "# **comments** (*true*): Cuando esta opción está " -"habilitada (por defecto), el contenido a incluir es envuelto por comentarios" -" `` y `` que ayudan a identificar " -"que el contenido ha sido incluido. Los valores posibles son `true` y " -"`false`." +"markdown_comments\"># **comments** (*false*): Cuando esta opción está " +"habilitada, el contenido a incluir es envuelto por comentarios `` y `` que ayudan a identificar que el " +"contenido ha sido incluido. Los valores posibles son `true` y `false`." msgid "" "# -**comments** (*true*): Lorsque cette option est activée (par défaut), le -contenu à inclure est entouré de `` et -`` commentaires qui aident à identifier que le contenu a été -inclus. Les valeurs possibles sont `true` et `false`. +**comments** (*false*): Lorsque cette option est activée, le contenu à inclure +est entouré de `` et `` commentaires +qui aident à identifier que le contenu a été inclus. Les valeurs possibles sont +`true` et `false`. - # **heading-offset** (0): Augmente ou diminue la profondeur des en-têtes Markdown de ce nombre. Ne prend en charge @@ -185,7 +185,7 @@ négatives pour supprimer les caractères `#` de tête. start='' end='' rewrite-relative-urls=false - comments=false + comments=true %} ``` diff --git a/locale/fr/README.md.po b/locale/fr/README.md.po index 0c717b1..17cbe55 100644 --- a/locale/fr/README.md.po +++ b/locale/fr/README.md.po @@ -130,16 +130,16 @@ msgstr "" msgid "" "# **comments** (*true*): When this option is enabled" -" (default), the content to include is wrapped by `` " -"and `` comments which help to identify that the content " -"has been included. Possible values are `true` and `false`." +"markdown_comments\"># **comments** (*false*): When this option is " +"enabled, the content to include is wrapped by `` and " +"`` comments which help to identify that the content has " +"been included. Possible values are `true` and `false`." msgstr "" "# **comments** (*true*): Lorsque cette option est " -"activée (par défaut), le contenu à inclure est entouré de `` et `` commentaires qui aident à identifier " -"que le contenu a été inclus. Les valeurs possibles sont `true` et `false`." +"markdown_comments\"># **comments** (*false*): Lorsque cette option est " +"activée, le contenu à inclure est entouré de `` et " +"`` commentaires qui aident à identifier que le contenu a" +" été inclus. Les valeurs possibles sont `true` et `false`." msgid "" "' end="" %}}''' - if directive == 'include': - includer_file_content = includer_file_content.replace( - 'comments=false', '', - ) result = on_page_markdown( includer_file_content, page(tmp_path / 'includer.md'), @@ -118,13 +113,8 @@ def test_invalid_start_end_arguments( includer_file_content = f''' {{% {directive} "{page_to_include_filepath}" - comments=false {argument}='' %}}''' - if directive == 'include': - includer_file_content = includer_file_content.replace( - 'comments=false', '', - ) with pytest.raises(PluginError) as exc: on_page_markdown( includer_file_content, @@ -160,13 +150,8 @@ def test_exclude_double_quote_escapes( includer_glob = os.path.join(str(drectory_to_include), '*.md') includer_file_content = f'''{{% {directive} "{includer_glob}" - comments=false exclude="{page_to_exclude_escaped_filepath}" %}}''' - if directive == 'include': - includer_file_content = includer_file_content.replace( - 'comments=false', '', - ) result = on_page_markdown( includer_file_content, page(tmp_path / 'includer.md'), @@ -193,13 +178,8 @@ def test_invalid_exclude_argument(directive, page, tmp_path, caplog, plugin): includer_file_content = f'''{{% {directive} "{includer_glob}" - comments=false exclude= %}}''' - if directive == 'include': - includer_file_content = includer_file_content.replace( - 'comments=false', '', - ) with pytest.raises(PluginError) as exc: on_page_markdown( @@ -223,13 +203,8 @@ def test_empty_encoding_argument(directive, page, tmp_path, plugin, caplog): includer_file_content = f'''{{% {directive} "{page_to_include_filepath}" - comments=false encoding= %}}''' - if directive == 'include': - includer_file_content = includer_file_content.replace( - 'comments=false', '', - ) with pytest.raises(PluginError) as exc: on_page_markdown( @@ -280,7 +255,6 @@ def test_invalid_heading_offset_arguments( on_page_markdown( f'''{{% include-markdown "{page_to_include_filepath}" - comments=false heading-offset={argument_value} %}}''', page(tmp_path / 'includer.md'), @@ -299,13 +273,8 @@ def test_invalid_argument_name(directive, page, tmp_path, plugin, caplog): includer_file_content = f'''{{% {directive} "{page_to_include_filepath}" - comments=false invalid-argument=true %}}''' - if directive == 'include': - includer_file_content = includer_file_content.replace( - 'comments=false', '', - ) assert on_page_markdown( includer_file_content, page(tmp_path / 'includer.md'), @@ -368,7 +337,6 @@ def test_escaped_double_quotes( result = on_page_markdown( f'''{{% {directive} "{escaped_page_to_include_filepath}" - {'comments=false' if directive == 'include-markdown' else ''} %}}''', page(tmp_path / 'includer.md'), tmp_path, @@ -392,7 +360,6 @@ def test_escaped_single_quotes( result = on_page_markdown( f'''{{% {directive} '{escaped_page_to_include_filepath}' - {'comments=false' if directive == 'include-markdown' else ''} %}}''', page(tmp_path / 'includer.md'), tmp_path, @@ -413,7 +380,6 @@ def test_unescaped_double_quotes( result = on_page_markdown( f'''{{% {directive} '{page_to_include_filepath}' - {'comments=false' if directive == 'include-markdown' else ''} %}}''', page(tmp_path / 'includer.md'), tmp_path, @@ -433,7 +399,6 @@ def test_unescaped_single_quotes( result = on_page_markdown( f'''{{% {directive} "{page_to_include_filepath}" - {'comments=false' if directive == 'include-markdown' else ''} %}}''', page(tmp_path / 'includer.md'), tmp_path, @@ -476,7 +441,6 @@ def test_mixed_quotes( markdown = f'''{{% {directive} {quote}{escaped_page_to_include_filepath}{quote} - {'comments=false' if directive == 'include-markdown' else ''} %}}''' func = functools.partial( diff --git a/tests/test_unit/test_config.py b/tests/test_unit/test_config.py index adb4ed3..324e86a 100644 --- a/tests/test_unit/test_config.py +++ b/tests/test_unit/test_config.py @@ -141,15 +141,15 @@ def _run_test( pytest.param( '{% include-markdown "{filepath}" %}', 'foo\n', - '\nfoo\n\n', - {}, + 'foo\n', + {'comments': False}, id='default-comments', ), pytest.param( - '{% include-markdown "{filepath}" %}', + '{% include-markdown "{filepath}" comments=true %}', 'foo\n', - 'foo\n', - {'comments': False}, + '\nfoo\n\n', + {}, id='custom-comments', ), ), diff --git a/tests/test_unit/test_encoding.py b/tests/test_unit/test_encoding.py index 7b125eb..377441f 100644 --- a/tests/test_unit/test_encoding.py +++ b/tests/test_unit/test_encoding.py @@ -18,7 +18,6 @@ def test_encoding(directive, page, tmp_path, plugin): on_page_markdown( f'''{{% {directive} "{page_to_include_file}" - comments=false start='' end="" encoding="ascii" @@ -43,7 +42,6 @@ def test_default_encoding(directive, page, tmp_path, plugin): result = on_page_markdown( f'''{{% {directive} "{page_to_include_file}" - comments=false start="" end="" %}}''', @@ -68,7 +66,6 @@ def test_explicit_default_encoding(directive, page, tmp_path, plugin): result = on_page_markdown( f'''{{% {directive} "{page_to_include_file}" - comments=false start='' end="" encoding="utf-8" diff --git a/tests/test_unit/test_exclude.py b/tests/test_unit/test_exclude.py index 9f58d47..f0681d5 100644 --- a/tests/test_unit/test_exclude.py +++ b/tests/test_unit/test_exclude.py @@ -85,11 +85,7 @@ def test_exclude( includer_file_content = f'''{{% {directive} "{tmp_path}{os.sep}content/*" exclude='{exclude_prefix}{exclude}' - comments=false %}}''' - if directive == 'include': - includer_file_content = includer_file_content.replace( - 'comments=false', '') for basename, file in files.items(): file.write_text(f'{basename}\n') diff --git a/tests/test_unit/test_glob_include.py b/tests/test_unit/test_glob_include.py index 6406a00..8eedcbf 100644 --- a/tests/test_unit/test_glob_include.py +++ b/tests/test_unit/test_glob_include.py @@ -58,14 +58,12 @@ def test_glob_include_absolute(page, tmp_path, plugin): {directive} "./included*.txt" start="" end="" - comments=false %} {% {directive} "./included*.txt" start="" end="" - comments=false %} ''', [], @@ -75,7 +73,6 @@ def test_glob_include_absolute(page, tmp_path, plugin): '''{% {directive} "./included*.txt" end="" - comments=false %} ''', [], @@ -88,21 +85,19 @@ def test_glob_include_absolute(page, tmp_path, plugin): {directive} "./included*.txt" start="" end="" - comments=false %} {% {directive} "./included*.txt" start="" end="" - comments=false %} ''', [ ( "Delimiter end ''" " of '{directive}' directive" - ' at {includer_file}:10 not detected in' + ' at {includer_file}:9 not detected in' ' the files {included_file_01}, {included_file_02}' ), ( @@ -114,7 +109,7 @@ def test_glob_include_absolute(page, tmp_path, plugin): ( "Delimiter start ''" " of '{directive}' directive" - ' at {includer_file}:10 not detected in' + ' at {includer_file}:9 not detected in' ' the files {included_file_01}, {included_file_02}' ), ( @@ -137,9 +132,6 @@ def test_glob_include( caplog, tmp_path, ): - if directive == 'include': - includer_content = includer_content.replace('comments=false', '') - includer_file = tmp_path / 'includer.txt' included_01_file = tmp_path / 'included_01.txt' included_02_file = tmp_path / 'included_02.txt' diff --git a/tests/test_unit/test_include.py b/tests/test_unit/test_include.py index 2316e0b..2c1bf13 100644 --- a/tests/test_unit/test_include.py +++ b/tests/test_unit/test_include.py @@ -102,7 +102,6 @@ include-markdown "{filepath}" start="" end="" - comments=false %}''', '''Some text diff --git a/tests/test_unit/test_include_markdown.py b/tests/test_unit/test_include_markdown.py index 30b6066..e4afbe6 100644 --- a/tests/test_unit/test_include_markdown.py +++ b/tests/test_unit/test_include_markdown.py @@ -19,9 +19,7 @@ 'This must be included.', '''# Header - This must be included. - ''', [], id='simple case', @@ -41,10 +39,8 @@ This must be included.''', '''# Header - This must be included. - ''', [], id='start', @@ -64,10 +60,8 @@ This must be ignored.''', '''# Header - This must be included. - ''', [], id='end', @@ -81,6 +75,7 @@ include-markdown "{filepath}" start="" end="" + comments=true %} ''', '''This must be ignored. @@ -108,6 +103,7 @@ include-markdown "{filepath}" start="" end="" + comments=true %} ''', '''This must be ignored. @@ -135,6 +131,7 @@ include-markdown "{filepath}" start="" end="" + comments=true %} ''', '''This must be ignored. @@ -158,14 +155,11 @@ # Exclude start and end comments pytest.param( - '''{% - include-markdown "{filepath}" - comments=false -%}''', + '{% include-markdown "{filepath}" %}', '''Foo''', '''Foo''', [], - id='comments=false', + id='comments=false (default)', ), # Multiples start and end matchs @@ -174,7 +168,6 @@ include-markdown "{filepath}" start="" end="" - comments=false %}''', '''Some text @@ -214,7 +207,6 @@ '''1. Ordered list item {% include-markdown "{filepath}" - comments=false preserve-includer-indent=false %}''', '''- Unordered sublist item @@ -232,7 +224,6 @@ {% include-markdown "{filepath}" start="" - comments=false %}''', '''Some text @@ -253,7 +244,6 @@ {% include-markdown "{filepath}" end='' - comments=false %}''', ''' Some text @@ -274,7 +264,6 @@ {% include-markdown '{filepath}' start='' - comments=false %}''', '''Some text ''', @@ -296,7 +285,6 @@ {% include-markdown "{filepath}" end="" - comments=false %}''', ''' Some text @@ -318,10 +306,7 @@ # Preserve includer indent pytest.param( '''1. Ordered list item - {% - include-markdown "{filepath}" - comments=false - %}''', + {% include-markdown "{filepath}" %}''', '''- First unordered sublist item - Second unordered sublist item - Third unordered sublist item''', @@ -340,7 +325,6 @@ include-markdown "{filepath}" preserve-includer-indent=true end="" - comments=false start="" %}''', '''- First unordered sublist item @@ -360,7 +344,6 @@ {% include-markdown "{filepath}" dedent=true - comments=false %} ''', ''' - Foo @@ -384,7 +367,6 @@ include-markdown "{filepath}" dedent=true preserve-includer-indent=true - comments=false %} ''', ''' - Foo @@ -414,11 +396,9 @@ Example data''', '''# Header - ## This should be a second level heading. Example data - ''', [], id='heading-offset=1', @@ -436,11 +416,9 @@ Example data''', '''# Header - ### This should be a third level heading. Example data - ''', [], id='heading-offset=2', @@ -459,11 +437,9 @@ Example data''', '''# Header - # This should be a first level heading. Example data - ''', [], id='no heading-offset (default)', @@ -483,11 +459,9 @@ Example data''', '''# Header - # This should be a first level heading. Example data - ''', [], id='heading-offset=0', @@ -507,11 +481,9 @@ Example data''', '''# Header - ## This should be a second level heading. Example data - ''', [], id='heading-offset=-2', @@ -531,11 +503,9 @@ Example data''', '''# Header - ''' + '#' * 94 + ''' This should be a 94th level heading. Example data - ''', [], id='heading-offset=90', @@ -555,11 +525,9 @@ Example data''', '''# Header - # This should be a first level heading. Example data - ''', [], id='heading-offset=-90', @@ -571,6 +539,7 @@ {% include-markdown "https://raw.githubusercontent.com/mondeja/mkdocs-include-markdown-plugin/master/examples/basic/docs/included.md" + comments=true %} After include. @@ -593,7 +562,7 @@ id='url', ), - # Custom encoding + # UTF-8 characters pytest.param( '''# Header @@ -615,7 +584,6 @@ ''', '''# Header - Тест інклуде азъ два @@ -630,7 +598,6 @@ ɡɫɐˈɡolʲɡ/ or /gʲЖж год god ДдД д дэdɐˈbro - ''', [], id='russian-characters', @@ -639,7 +606,7 @@ # Right strip unix trailing newlines pytest.param( '''1. List item number 1 -1. {% include-markdown "{filepath}" comments=false trailing-newlines=false %} +1. {% include-markdown "{filepath}" trailing-newlines=false %} 1. List item number 3 ''', 'Content to include\n', @@ -673,7 +640,7 @@ # Right strip trailing newlines keeping comments pytest.param( '''1. List item number 1 -1. {% include-markdown "{filepath}" trailing-newlines=false %} +1. {% include-markdown "{filepath}" trailing-newlines=false comments=true %} 1. List item number 3 ''', 'Content to include\n', @@ -690,6 +657,7 @@ 1. {% include-markdown "{filepath}" trailing-newlines=false + comments=true %} 1. List item number 3 ''', @@ -705,7 +673,9 @@ pytest.param( ( "{% include-markdown \"{filepath}\"" - " start='' %}" + " start=''" + " comments=true" + " %}" ), '''Ignored content @@ -726,6 +696,7 @@ 1. {% include-markdown "{filepath}" + comments=true %} 1. If everything works as expected this should be number 3 @@ -836,6 +807,7 @@ def test_include_markdown_relative_rewrite( include-markdown "./docs/page.md" start="" end="" + comments=true {option_value} %}} ''', @@ -902,14 +874,12 @@ def test_multiple_includes(page, tmp_path, plugin): {{% include-markdown "{snippet_filepath}" - comments=false %}} # Heading 2 {{% include-markdown "{another_filepath}" - comments=false %}} # Heading 3 diff --git a/tests/test_unit/test_logging.py b/tests/test_unit/test_logging.py index cb180d1..ff9ef78 100644 --- a/tests/test_unit/test_logging.py +++ b/tests/test_unit/test_logging.py @@ -25,7 +25,6 @@ def test_start_end_arguments_not_found( {{% {directive} "{included_file}" - comments=false start="" end="" %}} diff --git a/tests/test_unit/test_nested_includes.py b/tests/test_unit/test_nested_includes.py index d157b01..4f7f175 100644 --- a/tests/test_unit/test_nested_includes.py +++ b/tests/test_unit/test_nested_includes.py @@ -20,13 +20,11 @@ {% include-markdown "{filepath}" - comments=false %}''', '''Some text from second includer. {% include-markdown "{filepath}" - comments=false %} ''', '''Some test from final included.''', @@ -46,7 +44,6 @@ {% include-markdown "{filepath}" - comments=false %}''', '''Some text from second includer. @@ -102,7 +99,6 @@ include-markdown "{filepath}" start="" end="" - comments=false %} ''', '''This must be ignored @@ -127,14 +123,12 @@ {% include-markdown "{filepath}" heading-offset=1 - comments=false %}''', '''# Header 2 {% include-markdown "{filepath}" heading-offset=1 - comments=false %} ''', '''# Header 3 @@ -156,7 +150,6 @@ {% include-markdown '{filepath}' - comments=false start="" end="" %}''', @@ -190,13 +183,11 @@ {% include-markdown "{filepath}" - comments=false %}''', '''# Header 2 {% include-markdown "{filepath}" - comments=false start="" end="" %}''', @@ -258,7 +249,6 @@ {% include-markdown "{filepath}" recursive=false - comments=false %}''', '''# Header 2 @@ -345,7 +335,6 @@ def test_nested_include_relpath(page, tmp_path, plugin): {% include-markdown "./docs/second-includer.txt" - comments=false %} ''' first_includer_file.write_text(first_includer_content) @@ -354,7 +343,6 @@ def test_nested_include_relpath(page, tmp_path, plugin): {% include-markdown "../included.txt" - comments=false %} ''' second_includer_file.write_text(second_includer_content)