diff --git a/config_schema.json b/config_schema.json index fb30d95..7176a87 100644 --- a/config_schema.json +++ b/config_schema.json @@ -103,9 +103,9 @@ "cssclass": "highlight jumbotron" }, "tables": null, - "break-on-newline": true + "breaks": {"on_newline": true, "on_backslash": true} }, - "description": "[Markdown 2 options](https://github.com/trentm/python-markdown2/wiki/Extras) for the descriptions. `description_is_markdown` must be true for this to have any effect.\n\n**WARNING**\nAdding an extra, even if the value is false, will activate it. For example `{\"break-on-newline\": false}` will activate the `break-on-newline` extra.", + "description": "(Only used with `description_is_markdown`)\n[Markdown 2 options](https://github.com/trentm/python-markdown2/wiki/Extras) for the descriptions.", "examples": [ { "fenced-code-blocks": { diff --git a/docs/examples/examples_flat_default/Configuration.html b/docs/examples/examples_flat_default/Configuration.html index 78157d5..ae40f57 100644 --- a/docs/examples/examples_flat_default/Configuration.html +++ b/docs/examples/examples_flat_default/Configuration.html @@ -745,7 +745,7 @@
Markdown 2 options for the descriptions. description_is_markdown
must be true for this to have any effect.
WARNING
-Adding an extra, even if the value is false, will activate it. For example {"break-on-newline": false}
will activate the break-on-newline
extra.
(Only used with description_is_markdown
)
+Markdown 2 options for the descriptions.
Markdown 2 options for the descriptions. description_is_markdown
must be true for this to have any effect.
WARNING
-Adding an extra, even if the value is false, will activate it. For example {"break-on-newline": false}
will activate the break-on-newline
extra.
(Only used with description_is_markdown
)
+Markdown 2 options for the descriptions.
Markdown 2 options for the descriptions. description_is_markdown
must be true for this to have any effect.
WARNING
-Adding an extra, even if the value is false, will activate it. For example {"break-on-newline": false}
will activate the break-on-newline
extra.
(Only used with description_is_markdown
)
+Markdown 2 options for the descriptions.
-| | | -| ------------------------- | ------------------------------------------------------------------------------------------------------- | -| **Type** | `object` | -| **Required** | No | -| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | -| **Default** | `{"fenced-code-blocks": {"cssclass": "highlight jumbotron"}, "tables": null, "break-on-newline": true}` | - -**Description:** [Markdown 2 options](https://github.com/trentm/python-markdown2/wiki/Extras) for the descriptions. `description_is_markdown` must be true for this to have any effect. - -**WARNING** -Adding an extra, even if the value is false, will activate it. For example `{"break-on-newline": false}` will activate the `break-on-newline` extra. +| | | +| ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | +| **Type** | `object` | +| **Required** | No | +| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | +| **Default** | `{"fenced-code-blocks": {"cssclass": "highlight jumbotron"}, "tables": null, "breaks": {"on_newline": true, "on_backslash": true}}` | + +**Description:** (Only used with `description_is_markdown`) +[Markdown 2 options](https://github.com/trentm/python-markdown2/wiki/Extras) for the descriptions. **Example:** diff --git a/docs/examples/examples_md_nested_with_badges/Configuration.md b/docs/examples/examples_md_nested_with_badges/Configuration.md index 0f4786b..5196c99 100644 --- a/docs/examples/examples_md_nested_with_badges/Configuration.md +++ b/docs/examples/examples_md_nested_with_badges/Configuration.md @@ -387,16 +387,14 @@ This is the old behaviour and is only needed for browsers that do not support HT-| | | -| ------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | -| **Type** | `object` | -| **Additional properties** | [![Any type: allowed](https://img.shields.io/badge/Any%20type-allowed-green)](# "Additional Properties of any type are allowed.") | -| **Default** | `{"fenced-code-blocks": {"cssclass": "highlight jumbotron"}, "tables": null, "break-on-newline": true}` | - -**Description:** [Markdown 2 options](https://github.com/trentm/python-markdown2/wiki/Extras) for the descriptions. `description_is_markdown` must be true for this to have any effect. - -**WARNING** -Adding an extra, even if the value is false, will activate it. For example `{"break-on-newline": false}` will activate the `break-on-newline` extra. +| | | +| ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | +| **Type** | `object` | +| **Additional properties** | [![Any type: allowed](https://img.shields.io/badge/Any%20type-allowed-green)](# "Additional Properties of any type are allowed.") | +| **Default** | `{"fenced-code-blocks": {"cssclass": "highlight jumbotron"}, "tables": null, "breaks": {"on_newline": true, "on_backslash": true}}` | + +**Description:** (Only used with `description_is_markdown`) +[Markdown 2 options](https://github.com/trentm/python-markdown2/wiki/Extras) for the descriptions. **Example:** diff --git a/docs/examples/examples_md_with_badges/Configuration.md b/docs/examples/examples_md_with_badges/Configuration.md index 0ea67ae..e21d608 100644 --- a/docs/examples/examples_md_with_badges/Configuration.md +++ b/docs/examples/examples_md_with_badges/Configuration.md @@ -64,7 +64,7 @@ Configuration parameters can be provided in several ways: | - [show_toc](#show_toc ) | No | boolean | No | - | Whether to render table of contents. | | - [examples_as_yaml](#examples_as_yaml ) | No | boolean | No | - | Whether to display examples as YAML instead of JSON | | - [old_anchor_links](#old_anchor_links ) | No | boolean | No | - | Generate HTML ids for anchor links without special characters (keep only letters, digits, \`_\`, and \`-\`).
This is the old behaviour and is only needed for browsers that do not support HTML 5. | -| - [markdown_options](#markdown_options ) | No | object | No | - | [Markdown 2 options](https://github.com/trentm/python-markdown2/wiki/Extras) for the descriptions. \`description_is_markdown\` must be true for this to have any effect.
**WARNING**
Adding an extra, even if the value is false, will activate it. For example \`{"break-on-newline": false}\` will activate the \`break-on-newline\` extra. | +| - [markdown_options](#markdown_options ) | No | object | No | - | (Only used with \`description_is_markdown\`)
[Markdown 2 options](https://github.com/trentm/python-markdown2/wiki/Extras) for the descriptions. | | - [template_md_options](#template_md_options ) | No | object | No | - | specific options to md template | | - [with_footer](#with_footer ) | No | boolean | No | - | Whether to show the footer linking to the library repo and with the generation datetime | | - [footer_show_time](#footer_show_time ) | No | boolean | No | - | Whether the footer should display the generation time | @@ -273,16 +273,14 @@ This is the old behaviour and is only needed for browsers that do not support HT ## 18. ![Optional](https://img.shields.io/badge/Optional-yellow) Property `JSON Schema for Humans configuration file > markdown_options` -| | | -| ------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | -| **Type** | `object` | -| **Additional properties** | [![Any type: allowed](https://img.shields.io/badge/Any%20type-allowed-green)](# "Additional Properties of any type are allowed.") | -| **Default** | `{"fenced-code-blocks": {"cssclass": "highlight jumbotron"}, "tables": null, "break-on-newline": true}` | - -**Description:** [Markdown 2 options](https://github.com/trentm/python-markdown2/wiki/Extras) for the descriptions. `description_is_markdown` must be true for this to have any effect. +| | | +| ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | +| **Type** | `object` | +| **Additional properties** | [![Any type: allowed](https://img.shields.io/badge/Any%20type-allowed-green)](# "Additional Properties of any type are allowed.") | +| **Default** | `{"fenced-code-blocks": {"cssclass": "highlight jumbotron"}, "tables": null, "breaks": {"on_newline": true, "on_backslash": true}}` | -**WARNING** -Adding an extra, even if the value is false, will activate it. For example `{"break-on-newline": false}` will activate the `break-on-newline` extra. +**Description:** (Only used with `description_is_markdown`) +[Markdown 2 options](https://github.com/trentm/python-markdown2/wiki/Extras) for the descriptions. **Example:** diff --git a/json_schema_for_humans/generation_configuration.py b/json_schema_for_humans/generation_configuration.py index 759684c..1031eed 100644 --- a/json_schema_for_humans/generation_configuration.py +++ b/json_schema_for_humans/generation_configuration.py @@ -61,12 +61,17 @@ class GenerationConfiguration: footer_show_time: bool = True def __post_init__(self) -> None: - default_markdown_options = { - "break-on-newline": True, + self.markdown_options = self.markdown_options or {} + default_markdown_options: Dict[str, Any] = { "fenced-code-blocks": {"cssclass": "highlight jumbotron"}, "tables": None, } - default_markdown_options.update(self.markdown_options or {}) + if "breaks" not in self.markdown_options: + default_markdown_options["breaks"] = { + "on_newline": True, + "on_backslash": True, + } + default_markdown_options.update(self.markdown_options) self.markdown_options = default_markdown_options default_template_md_options = { diff --git a/tests/generation_configuration_test.py b/tests/generation_configuration_test.py index 2f3835a..6f7b0af 100644 --- a/tests/generation_configuration_test.py +++ b/tests/generation_configuration_test.py @@ -6,7 +6,10 @@ def test_default_values() -> None: """Test init GenerationConfiguration with default values""" config = GenerationConfiguration() assert config.markdown_options == { - "break-on-newline": True, + "breaks": { + "on_newline": True, + "on_backslash": True, + }, "fenced-code-blocks": {"cssclass": "highlight jumbotron"}, "tables": None, } @@ -18,9 +21,9 @@ def test_override_markdown_options() -> None: """Test init GenerationConfiguration with default values""" # override break-on-newline key - config = GenerationConfiguration(markdown_options={"break-on-newline": False}) + config = GenerationConfiguration(markdown_options={"breaks": {"on_newline": False}}) assert config.markdown_options == { - "break-on-newline": False, + "breaks": {"on_newline": False}, "fenced-code-blocks": {"cssclass": "highlight jumbotron"}, "tables": None, } @@ -31,14 +34,14 @@ def test_override_markdown_options() -> None: } ) assert config.markdown_options == { - "break-on-newline": True, + "breaks": {"on_newline": True, "on_backslash": True}, "fenced-code-blocks": {"cssclass": "test"}, "tables": None, } # override tables key config = GenerationConfiguration(markdown_options={"tables": ["test"]}) assert config.markdown_options == { - "break-on-newline": True, + "breaks": {"on_newline": True, "on_backslash": True}, "fenced-code-blocks": {"cssclass": "highlight jumbotron"}, "tables": ["test"], } @@ -46,7 +49,7 @@ def test_override_markdown_options() -> None: # add a new key config = GenerationConfiguration(markdown_options={"newKey": "test"}) assert config.markdown_options == { - "break-on-newline": True, + "breaks": {"on_newline": True, "on_backslash": True}, "fenced-code-blocks": {"cssclass": "highlight jumbotron"}, "tables": None, "newKey": "test",