diff --git a/json_schema_for_humans/jinja_filters.py b/json_schema_for_humans/jinja_filters.py index 4c19e4a..3d1a603 100644 --- a/json_schema_for_humans/jinja_filters.py +++ b/json_schema_for_humans/jinja_filters.py @@ -193,12 +193,12 @@ def deprecated(config, schema: SchemaNode) -> bool: return is_deprecated_look_in_description(schema) if config.deprecated_from_description else is_deprecated(schema) -def first_line(example_text: str, max_length: int = 0) -> str: +def first_line(example_text: str) -> str: """Filter. Retrieve first line of string + add ... at the end if text has multiple lines cut line at max_length""" lines = example_text.splitlines() result = lines[0] - etc = (max_length and len(result) > max_length) or len(lines) > 1 - return f"{result[:max_length]}{' ...' if etc else ''}" + etc = len(lines) > 1 + return f"{result}{' ...' if etc else ''}" def get_local_time() -> str: diff --git a/json_schema_for_humans/md_template.py b/json_schema_for_humans/md_template.py index 2d4550e..d6b7948 100644 --- a/json_schema_for_humans/md_template.py +++ b/json_schema_for_humans/md_template.py @@ -151,9 +151,9 @@ def array_items(schema: SchemaNode, title: str) -> List[List[str]]: return items -def first_line_fixed(example_text: str, max_length: int = 0) -> str: - """first_line truncated but replace ` with ' to avoid to have only one ` to avoid issues with jekyll""" - return jinja_filters.first_line(example_text, max_length).translate(str.maketrans({"`": "'"})) +def first_line_fixed(example_text: str) -> str: + """first_line but replace ` with ' to avoid unbalanced `s in markdown""" + return jinja_filters.first_line(example_text).translate(str.maketrans({"`": "'"})) def array_items_restrictions(schema: SchemaNode) -> List[List[str]]: @@ -174,7 +174,7 @@ def array_items_restrictions(schema: SchemaNode) -> List[List[str]]: items_restrictions.append( [ f"[{item_label}](#{item_html_id})", - escape_for_table(first_line_fixed(item.description or "-", const.LINE_WIDTH)), + escape_for_table(first_line_fixed(item.description or "-")), ] ) @@ -200,7 +200,6 @@ def register_jinja(self, env: jinja2.Environment): env.filters["md_array_items"] = array_items env.filters["md_restrictions_table"] = restrictions_table env.filters["md_generate_table"] = generate_table - env.filters["md_first_line"] = first_line_fixed env.globals["md_badge"] = self.badge env.globals["md_get_toc"] = self.get_toc diff --git a/pyproject.toml b/pyproject.toml index 31f6890..03126e3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "json-schema-for-humans" -version = "0.45.0" +version = "0.46.0" description = "Generate static HTML documentation from JSON schemas" authors = ["Denis Blanchette ", "AbdulRahman Al Hamali "] license = "Apache-2.0"