Skip to content

Commit fd4d6db

Browse files
committed
fix: Markdown code environment not honored when generating description in glossary
1 parent 6c32e86 commit fd4d6db

File tree

2 files changed

+13
-17
lines changed

2 files changed

+13
-17
lines changed

src/schema/objects/metaentities.yaml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,22 @@ matches:
3434
`matches` is used as a placeholder in BIDS filenames templates to denote that several files
3535
share exactly the same sequence of entities and labels in their basename.
3636
37-
For example, in the following filename template:
37+
For example, in the following filename template:
3838
39-
```
40-
<matches>_bold.nii.gz
41-
<matches>_events.tsv
42-
<matches>_events.json
43-
```
39+
```Text
40+
<matches>_bold.nii.gz
41+
<matches>_events.tsv
42+
<matches>_events.json
43+
```
4444
45-
`<matches>` could correspond to `sub-control01_task-nback_run-1`.
45+
`<matches>` could correspond to `sub-control01_task-nback_run-1`.
4646
4747
source_entities:
4848
name: source_entities
4949
display_name: source entities
5050
description: |
5151
`source_entities` is used as a placeholder in BIDS derivatives filenames templates.
5252
53-
`source_entities` MUST be the entire source filename, with the omission of
54-
the source suffix and extension.
55-
One exception to this rule is filename entities that are no longer relevant.
53+
`source_entities` MUST be the entire source filename, with the omission of
54+
the source suffix and extension.
55+
One exception to this rule is filename entities that are no longer relevant.

tools/schemacode/src/bidsschematools/render/text.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,6 @@ def make_glossary(schema, src_path=None):
151151
obj_desc = obj_def.get("description", None)
152152
if obj_desc is None:
153153
raise ValueError(f"{obj_marker} has no description.")
154-
# A backslash before a newline means continue a string
155-
obj_desc = obj_desc.replace("\\\n", "")
156-
# Two newlines should be respected
157-
obj_desc = obj_desc.replace("\n\n", "<br>")
158-
# Otherwise a newline corresponds to a space
159-
obj_desc = obj_desc.replace("\n", " ")
160154

161155
text += f'\n<a name="{obj_marker}"></a>'
162156
text += f"\n## {obj_key}\n\n"
@@ -184,7 +178,9 @@ def make_glossary(schema, src_path=None):
184178
levels = [level["name"] if isinstance(level, dict) else level for level in levels]
185179
text += f"**Allowed values**: `{'`, `'.join(levels)}`\n\n"
186180

187-
text += f"**Description**:\n{obj_desc}\n\n"
181+
# Convert description into markdown and append to text
182+
obj_desc = MarkdownIt().render(f"**Description**:\n{obj_desc}")
183+
text += f"{obj_desc}\n\n"
188184

189185
reduced_obj_def = {k: v for k, v in obj_def.items() if k not in keys_to_drop}
190186

0 commit comments

Comments
 (0)