Skip to content

Commit

Permalink
feat: Add description_safe_mode config option (#283)
Browse files Browse the repository at this point in the history
* feat: Add `description_safe_mode` config option
  • Loading branch information
dblanchette authored Nov 29, 2024
1 parent dd28a3a commit a17ce95
Show file tree
Hide file tree
Showing 99 changed files with 2,051 additions and 4,918 deletions.
35 changes: 20 additions & 15 deletions config_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,15 @@
"title": "JSON Schema for Humans configuration file",
"description": "Choose how to generate JSON Schema for Humans documentation file.\n\nConfiguration parameters can be provided in several ways:\n\n- On the CLI using `--config parameter_name=value` (example: `--config template_name=flat`)\n- On the CLI using a config file `--config-file config.json`\n- From code, by providing a GenerationConfiguration object to the called generation method.",
"properties": {
"minify": {
"type": "boolean",
"default": true,
"description": "[Deprecated]"
},
"description_is_markdown": {
"type": "boolean",
"default": true,
"description": "Applies to HTML templates only. Whether to consider the description as Markdown and render it accordingly."
"description": "(HTML outputs only)\nWhether to consider the description as Markdown and render it accordingly."
},
"allow_html_description": {
"type": "boolean",
"default": false,
"description": "Applies to HTML templates only. Don't escape HTML tags in descriptions. Can be needed when description is Markdown and contains already escaped blocks"
"description_safe_mode": {
"enum": [null, "escape", "replace"],
"default": "escape",
"description": "(HTML outputs only)\n(Only used with `description_is_markdown`)\nHow are HTML tags in descriptions handled. Correspond to the `safe_mode` option of the markdown2 library.\n\n- \"escape\": Escape all HTML tags in descriptions\n- \"replace\": Replace HTML tags with `[HTML_REMOVED]`\n- null: Allow HTML in descriptions"
},
"expand_buttons": {
"type": "boolean",
Expand Down Expand Up @@ -52,7 +47,7 @@
"deprecated_from_description": {
"type": "boolean",
"default": false,
"description": "Mark a property as deprecated (with a big red badge) if the description contains the string `[Deprecated`."
"description": "Mark a property as deprecated (with a big red badge) if the description contains the string `[\u200BDeprecated`."
},
"default_from_description": {
"type": "boolean",
Expand All @@ -69,10 +64,6 @@
"default": true,
"description": "Copy `schema_doc.min.js` to the same directory as `RESULT_FILE` after generation.\n\nThis file contains the logic for the anchor links."
},
"templates_directory": {
"type": "string",
"description": "[Deprecated]"
},
"template_name": {
"type": "string",
"enum": [
Expand Down Expand Up @@ -171,6 +162,20 @@
"type": "boolean",
"description": "Whether the footer should display the generation time",
"default": true
},
"allow_html_description": {
"type": "boolean",
"default": false,
"description": "[Deprecated]"
},
"minify": {
"type": "boolean",
"default": true,
"description": "[Deprecated]"
},
"templates_directory": {
"type": "string",
"description": "[Deprecated]"
}
}
}
66 changes: 66 additions & 0 deletions docs/Examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -1608,6 +1608,72 @@ the description of an attribute
[examples/examples_md_nested_with_badges/geo.md](examples/examples_md_nested_with_badges/geo.md ':include')
</details>

## --html_in_description--
### html_in_description


<details>
<summary>Json schema - Click here to expand source code...</summary>

[examples/cases/html_in_description.json](examples/cases/html_in_description.json ':include :type=code')
</details>


<details>
<summary>JS template - Click here to expand the rendered result...</summary>
<a href="https://coveooss.github.io/json-schema-for-humans/examples/examples_js_default/html_in_description.html" target="_blank">Open it in full page</a>

[examples/examples_js_default/html_in_description.html](examples/examples_js_default/html_in_description.html ':include :type=iframe width=100% height=400px')
</details>


<details>
<summary>JS Offline template - Click here to expand the rendered result...</summary>
<a href="https://coveooss.github.io/json-schema-for-humans/examples/examples_js_offline_default/html_in_description.html" target="_blank">Open it in full page</a>

[examples/examples_js_offline_default/html_in_description.html](examples/examples_js_offline_default/html_in_description.html ':include :type=iframe width=100% height=400px')
</details>


<details>
<summary>Flat template - Click here to expand the rendered result...</summary>
<a href="https://coveooss.github.io/json-schema-for-humans/examples/examples_flat_default/html_in_description.html" target="_blank">Open it in full page</a>

[examples/examples_flat_default/html_in_description.html](examples/examples_flat_default/html_in_description.html ':include :type=iframe width=100% height=400px')
</details>


<details>
<summary>Markdown without badge template - Click here to expand the rendered result...</summary>
<a href="https://github.com/coveooss/json-schema-for-humans/blob/main/docs/examples/examples_md_default/html_in_description.md" target="_blank">Open it in github</a>

[examples/examples_md_default/html_in_description.md](examples/examples_md_default/html_in_description.md ':include')
</details>


<details>
<summary>Markdown with badges template - Click here to expand the rendered result...</summary>
<a href="https://github.com/coveooss/json-schema-for-humans/blob/main/docs/examples/examples_md_with_badges/html_in_description.md" target="_blank">Open it in github</a>

[examples/examples_md_with_badges/html_in_description.md](examples/examples_md_with_badges/html_in_description.md ':include')
</details>


<details>
<summary>Nested Markdown without badges template - Click here to expand the rendered result...</summary>
<a href="https://github.com/coveooss/json-schema-for-humans/blob/main/docs/examples/examples_md_nested_default/html_in_description.md" target="_blank">Open it in github</a>

[examples/examples_md_nested_default/html_in_description.md](examples/examples_md_nested_default/html_in_description.md ':include')
</details>


<details>
<summary>Nested Markdown with badges template - Click here to expand the rendered result...</summary>
<a href="https://github.com/coveooss/json-schema-for-humans/blob/main/docs/examples/examples_md_nested_with_badges/html_in_description.md" target="_blank">Open it in github</a>

[examples/examples_md_nested_with_badges/html_in_description.md](examples/examples_md_nested_with_badges/html_in_description.md ':include')
</details>

## --html_in_patterns--
### html_in_patterns

Expand Down
23 changes: 23 additions & 0 deletions docs/examples/cases/html_in_description.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"$id": "https://example.com/html.schema.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "HTML in descriptions",
"type": "object",
"properties": {
"raw_html": {
"type": "string",
"description": "<br/><br/><br/><br/><a href=\"https://example.com\">A link to example.com</a>",
"title": "Some raw HTML"
},
"html_in_markdown": {
"type": "string",
"description": "Here is some HTML:\n```html\n<br/><br/><br/><br/><a href=\"https://example.com\">A link to example.com</a>\n```",
"title": "Some HTML in Markdown"
},
"json_in_markdown": {
"type": "string",
"description": "Here is some JSON:\n```json\n{\n \"property\": \"value\"\n}\n```",
"title": "Some JSON in Markdown"
}
}
}
Loading

0 comments on commit a17ce95

Please sign in to comment.