Skip to content

Commit

Permalink
Set comments=false as default for include-markdown directive (#233)
Browse files Browse the repository at this point in the history
  • Loading branch information
mondeja authored Oct 22, 2024
1 parent ef88880 commit 7daca94
Show file tree
Hide file tree
Showing 20 changed files with 56 additions and 154 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,10 @@ content to include.
are rewritten to work correctly in their new location. Possible values are
`true` and `false`.
- <a name="include-markdown_comments" href="#include-markdown_comments">#</a>
**comments** (_true_): When this option is enabled (default), the content to
include is wrapped by `<!-- BEGIN INCLUDE -->` and `<!-- END INCLUDE -->`
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 `<!-- BEGIN INCLUDE -->` and `<!-- END INCLUDE -->` comments
which help to identify that the content has been included. Possible values
are `true` and `false`.
- <a name="include-markdown_heading-offset" href="#include-markdown_heading-offset">#</a>
**heading-offset** (0): Increases or decreases the Markdown headings depth
by this number. Only supports number sign (`#`) heading syntax. Accepts
Expand All @@ -193,7 +193,7 @@ content to include.
start='<!--\n\ttable-start\n-->'
end='<!--\n\ttable-end\n-->'
rewrite-relative-urls=false
comments=false
comments=true
%}
```

Expand Down
2 changes: 1 addition & 1 deletion examples/custom-tags/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

|>
include-markdown "./included.md"
comments=false
comments=true
<|

|> include './included.md' <|
2 changes: 1 addition & 1 deletion examples/start-end-not-found-warnings/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
include-markdown "./included.md"
start="<--start-->"
end="<--end-->"
comments=false
%}

{%
include './included.md'
start="<--start-->"
end="<--end-->"
comments=true
%}
1 change: 0 additions & 1 deletion examples/table-as-list-item/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

{%
include-markdown "./table.md"
comments=false
%}

1. Another list entry
Expand Down
6 changes: 3 additions & 3 deletions locale/es/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
- <a name="include-markdown_comments" href="#include-markdown_comments">#</a>
**comments** (*true*): Cuando esta opción está habilitada (por defecto), el
contenido a incluir es envuelto por comentarios `<!-- BEGIN INCLUDE -->` y
**comments** (*false*): Cuando esta opción está habilitada, el contenido a
incluir es envuelto por comentarios `<!-- BEGIN INCLUDE -->` y
`<!-- END INCLUDE -->` que ayudan a identificar que el contenido ha sido
incluido. Los valores posibles son `true` y `false`.
- <a name="include-markdown_heading-offset"
Expand All @@ -185,7 +185,7 @@ especificado. Sólo soporta la sintaxis de encabezado de caracteres de hash
start='<!--\n\ttable-start\n-->'
end='<!--\n\ttable-end\n-->'
rewrite-relative-urls=false
comments=false
comments=true
%}
```

Expand Down
17 changes: 8 additions & 9 deletions locale/es/README.md.po
Original file line number Diff line number Diff line change
Expand Up @@ -137,17 +137,16 @@ msgstr ""

msgid ""
"<a name=\"include-markdown_comments\" href=\"#include-"
"markdown_comments\">#</a> **comments** (*true*): When this option is enabled"
" (default), the content to include is wrapped by `<!-- BEGIN INCLUDE -->` "
"and `<!-- END INCLUDE -->` comments which help to identify that the content "
"has been included. Possible values are `true` and `false`."
"markdown_comments\">#</a> **comments** (*false*): When this option is "
"enabled, the content to include is wrapped by `<!-- BEGIN INCLUDE -->` and "
"`<!-- END INCLUDE -->` comments which help to identify that the content has "
"been included. Possible values are `true` and `false`."
msgstr ""
"<a name=\"include-markdown_comments\" href=\"#include-"
"markdown_comments\">#</a> **comments** (*true*): Cuando esta opción está "
"habilitada (por defecto), el contenido a incluir es envuelto por comentarios"
" `<!-- BEGIN INCLUDE -->` y `<!-- END INCLUDE -->` que ayudan a identificar "
"que el contenido ha sido incluido. Los valores posibles son `true` y "
"`false`."
"markdown_comments\">#</a> **comments** (*false*): Cuando esta opción está "
"habilitada, el contenido a incluir es envuelto por comentarios `<!-- BEGIN "
"INCLUDE -->` y `<!-- END INCLUDE -->` que ayudan a identificar que el "
"contenido ha sido incluido. Los valores posibles son `true` y `false`."

msgid ""
"<a name=\"include-markdown_heading-offset\" href=\"#include-"
Expand Down
10 changes: 5 additions & 5 deletions locale/fr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,10 @@ Markdown dans le contenu qui sont spécifiés par une URL relative sont réécri
pour fonctionner correctement dans leur nouvel emplacement. Les valeurs
possibles sont `true` et `false`.
- <a name="include-markdown_comments" href="#include-markdown_comments">#</a>
**comments** (*true*): Lorsque cette option est activée (par défaut), le
contenu à inclure est entouré de `<!-- BEGIN INCLUDE -->` et
`<!-- END INCLUDE -->` 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 `<!-- BEGIN INCLUDE -->` et `<!-- END INCLUDE -->` commentaires
qui aident à identifier que le contenu a été inclus. Les valeurs possibles sont
`true` et `false`.
- <a name="include-markdown_heading-offset"
href="#include-markdown_heading-offset">#</a> **heading-offset** (0): Augmente
ou diminue la profondeur des en-têtes Markdown de ce nombre. Ne prend en charge
Expand All @@ -185,7 +185,7 @@ négatives pour supprimer les caractères `#` de tête.
start='<!--\n\ttable-start\n-->'
end='<!--\n\ttable-end\n-->'
rewrite-relative-urls=false
comments=false
comments=true
%}
```

Expand Down
16 changes: 8 additions & 8 deletions locale/fr/README.md.po
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,16 @@ msgstr ""

msgid ""
"<a name=\"include-markdown_comments\" href=\"#include-"
"markdown_comments\">#</a> **comments** (*true*): When this option is enabled"
" (default), the content to include is wrapped by `<!-- BEGIN INCLUDE -->` "
"and `<!-- END INCLUDE -->` comments which help to identify that the content "
"has been included. Possible values are `true` and `false`."
"markdown_comments\">#</a> **comments** (*false*): When this option is "
"enabled, the content to include is wrapped by `<!-- BEGIN INCLUDE -->` and "
"`<!-- END INCLUDE -->` comments which help to identify that the content has "
"been included. Possible values are `true` and `false`."
msgstr ""
"<a name=\"include-markdown_comments\" href=\"#include-"
"markdown_comments\">#</a> **comments** (*true*): Lorsque cette option est "
"activée (par défaut), le contenu à inclure est entouré de `<!-- BEGIN "
"INCLUDE -->` et `<!-- END INCLUDE -->` commentaires qui aident à identifier "
"que le contenu a été inclus. Les valeurs possibles sont `true` et `false`."
"markdown_comments\">#</a> **comments** (*false*): Lorsque cette option est "
"activée, le contenu à inclure est entouré de `<!-- BEGIN INCLUDE -->` et "
"`<!-- END INCLUDE -->` commentaires qui aident à identifier que le contenu a"
" été inclus. Les valeurs possibles sont `true` et `false`."

msgid ""
"<a name=\"include-markdown_heading-offset\" href=\"#include-"
Expand Down
2 changes: 1 addition & 1 deletion lychee.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ exclude = [
'https://raw\.githubusercontent\.com/mondeja/',
'https://github.com/user/repo'
]
exclude_path = ["lychee.toml"]
exclude_path = ["lychee.toml", "^locale"]
2 changes: 1 addition & 1 deletion src/mkdocs_include_markdown_plugin/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class PluginConfig(Config): # noqa: D101
preserve_includer_indent = MkType(bool, default=True)
dedent = MkType(bool, default=False)
trailing_newlines = MkType(bool, default=True)
comments = MkType(bool, default=True)
comments = MkType(bool, default=False)
rewrite_relative_urls = MkType(bool, default=True)
heading_offset = MkType(int, default=0)
start = Optional(MkType(str))
Expand Down
1 change: 0 additions & 1 deletion tests/test_integration/test_cache_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ def run():
return on_page_markdown(
f'''{{%
{directive} "{url}"
comments=false
%}}''',
page(tmp_path / 'includer.md'),
tmp_path,
Expand Down
36 changes: 0 additions & 36 deletions tests/test_unit/test_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,9 @@ def test_start_end_mixed_quotes(directive, page, caplog, tmp_path, plugin):

includer_file_content = f'''{{%
{directive} "{page_to_include_filepath}"
comments=false
start='<!-- "s\\'tar\\'t" -->'
end="<!-- 'en\\"d' -->"
%}}'''
if directive == 'include':
includer_file_content = includer_file_content.replace(
'comments=false', '',
)
result = on_page_markdown(
includer_file_content,
page(tmp_path / 'includer.md'),
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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'),
Expand All @@ -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(
Expand All @@ -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(
Expand Down Expand Up @@ -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'),
Expand All @@ -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'),
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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(
Expand Down
10 changes: 5 additions & 5 deletions tests/test_unit/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,15 @@ def _run_test(
pytest.param(
'{% include-markdown "{filepath}" %}',
'foo\n',
'<!-- BEGIN INCLUDE {filepath} -->\nfoo\n\n<!-- END INCLUDE -->',
{},
'foo\n',
{'comments': False},
id='default-comments',
),
pytest.param(
'{% include-markdown "{filepath}" %}',
'{% include-markdown "{filepath}" comments=true %}',
'foo\n',
'foo\n',
{'comments': False},
'<!-- BEGIN INCLUDE {filepath} -->\nfoo\n\n<!-- END INCLUDE -->',
{},
id='custom-comments',
),
),
Expand Down
3 changes: 0 additions & 3 deletions tests/test_unit/test_encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ def test_encoding(directive, page, tmp_path, plugin):
on_page_markdown(
f'''{{%
{directive} "{page_to_include_file}"
comments=false
start='<!-- start -->'
end="<!-- end -->"
encoding="ascii"
Expand All @@ -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="<!-- start -->"
end="<!-- end -->"
%}}''',
Expand All @@ -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='<!-- start -->'
end="<!-- end -->"
encoding="utf-8"
Expand Down
4 changes: 0 additions & 4 deletions tests/test_unit/test_exclude.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down
Loading

0 comments on commit 7daca94

Please sign in to comment.