Skip to content

Commit 67c3b01

Browse files
committed
Issue: #788: fixed nested inline markdown detection, added tests
1 parent 0e4108b commit 67c3b01

File tree

5 files changed

+245
-21
lines changed

5 files changed

+245
-21
lines changed

rt/markdown/err.txt

Lines changed: 137 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,17 @@ MARKDOWN MODULE
3434
Description
3535
This module demonstrates markdown formatting in help content.
3636
Features
37-
*Italicized* feature descriptions
38-
**Bold** important notes
39-
`inline code` examples
37+
• Italicized feature descriptions
38+
• Bold important notes
39+
• inline code examples
4040
• Structured content with headers
4141
Usage
4242
Code:
4343
module load markdown_content/2.0
4444
For more information, visit the project website (...).
4545
Installation Notes
4646
1. First step in installation
47-
2. Second step with **important** details
47+
2. Second step with important details
4848
3. Final configuration step
4949
===========================
5050
step 5
@@ -409,9 +409,9 @@ Screenshots
409409
[Image: Logo] (...)
410410
[Image: Screenshot] (...)
411411
Features
412-
• Feature one with **bold** text
413-
• Feature two with *italic* text
414-
• Feature three with `code` examples
412+
• Feature one with bold text
413+
• Feature two with italic text
414+
• Feature three with code examples
415415
For more information, visit the project website (...).
416416
===========================
417417
step 35
@@ -445,34 +445,119 @@ markdown_with_images/1.0 : Version: 1.0
445445
markdown_with_images/1.0 : Description: Tests markdown content with images
446446
===========================
447447
step 37
448+
lua ProjectDIR/src/lmod.in.lua shell --regression_testing help nested_markdown_lists/1.0
449+
===========================
450+
Module Specific Help for "nested_markdown_lists/1.0"
451+
NESTED MARKDOWN IN LISTS
452+
Overview
453+
This module tests that nested markdown formatting (bold, italic, code) within list items is correctly processed and rendered.
454+
Unordered Lists with Nested Formatting
455+
• Feature with bold text
456+
• Feature with italic text
457+
• Feature with code examples
458+
• Feature with bold and italic together
459+
• Feature with code and bold text
460+
• Feature with a link (...) inside
461+
Ordered Lists with Nested Formatting
462+
1. First item with bold emphasis
463+
2. Second item with italic emphasis
464+
3. Third item with code formatting
465+
4. Fourth item combining bold, italic, and code
466+
5. Fifth item with a link (...) and bold text
467+
Mixed Nested Formatting
468+
• Regular text without formatting
469+
• Text with bold only
470+
• Text with italic only
471+
• Text with code only
472+
• Text with bold and italic combined
473+
• Text with all three: bold, italic, and code
474+
• Text with links (...) and bold formatting
475+
Expected Behavior
476+
All nested formatting should be rendered correctly:
477+
• Bold text should appear bold
478+
• Italic text should appear italic
479+
• Code should appear with code formatting
480+
• Links (...) should be formatted as links
481+
If you see raw markdown syntax (like bold or italic) in the output, the nested formatting is not being processed correctly.
482+
===========================
483+
step 38
484+
lua ProjectDIR/src/lmod.in.lua shell --regression_testing show nested_markdown_lists/1.0
485+
===========================
486+
ProjectDIR/rt/markdown/mf/Core/nested_markdown_lists/1.0.lua:
487+
This help content will be processed as markdown in terminal display
488+
help([[# Nested Markdown in Lists
489+
## Overview
490+
This module tests that nested markdown formatting (bold, italic, code) within list items is correctly processed and rendered.
491+
## Unordered Lists with Nested Formatting
492+
Feature with **bold** text
493+
Feature with *italic* text
494+
Feature with `code` examples
495+
Feature with **bold** and *italic* together
496+
Feature with `code` and **bold** text
497+
Feature with a [link](https://example.com) inside
498+
## Ordered Lists with Nested Formatting
499+
1. First item with **bold** emphasis
500+
2. Second item with *italic* emphasis
501+
3. Third item with `code` formatting
502+
4. Fourth item combining **bold**, *italic*, and `code`
503+
5. Fifth item with a [link](https://example.com) and **bold** text
504+
## Mixed Nested Formatting
505+
Regular text without formatting
506+
Text with **bold** only
507+
Text with *italic* only
508+
Text with `code` only
509+
Text with **bold** and *italic* combined
510+
Text with all three: **bold**, *italic*, and `code`
511+
Text with [links](https://example.com) and **bold** formatting
512+
## Expected Behavior
513+
All nested formatting should be rendered correctly:
514+
**Bold** text should appear bold
515+
*Italic* text should appear italic
516+
`Code` should appear with code formatting
517+
[Links](https://example.com) should be formatted as links
518+
If you see raw markdown syntax (like `**bold**` or `*italic*`) in the output, the nested formatting is not being processed correctly.
519+
]])
520+
whatis("Name: Nested Markdown Lists Test")
521+
whatis("Version: 1.0")
522+
whatis("Description: Tests nested markdown formatting within list items")
523+
setenv("NESTED_MARKDOWN_LISTS_VERSION","1.0")
524+
===========================
525+
step 39
526+
lua ProjectDIR/src/lmod.in.lua shell --regression_testing whatis nested_markdown_lists/1.0
527+
===========================
528+
nested_markdown_lists/1.0 : Name: Nested Markdown Lists Test
529+
nested_markdown_lists/1.0 : Version: 1.0
530+
nested_markdown_lists/1.0 : Description: Tests nested markdown formatting within list items
531+
===========================
532+
step 40
448533
lua ProjectDIR/src/lmod.in.lua shell --regression_testing help markdown_content/2.0
449534
===========================
450535
Module Specific Help for "markdown_content/2.0"
451536
\\033[1m\\033[36mMARKDOWN MODULE\\033[0m
452537
\\033[1mDescription\\033[0m
453538
This module demonstrates \\033[1mmarkdown formatting\\033[0m in help content.
454539
\\033[1mFeatures\\033[0m
455-
\\033[36m•\\033[0m *Italicized* feature descriptions
456-
\\033[36m•\\033[0m **Bold** important notes
457-
\\033[36m•\\033[0m `inline code` examples
540+
\\033[36m•\\033[0m \\033[3mItalicized\\033[0m feature descriptions
541+
\\033[36m•\\033[0m \\033[1mBold\\033[0m important notes
542+
\\033[36m•\\033[0m \\033[2m\\033[36minline code\\033[0m examples
458543
\\033[36m•\\033[0m Structured content with headers
459544
\\033[1mUsage\\033[0m
460545
\\033[2mCode:\\033[0m
461546
\\033[2m\\033[36mmodule load markdown_content/2.0\\033[0m
462547
For more information, visit the \\033[34m\\033[4mproject website\\033[0m (...).
463548
\\033[4mInstallation Notes\\033[0m
464549
\\033[36m1.\\033[0m First step in installation
465-
\\033[36m2.\\033[0m Second step with **important** details
550+
\\033[36m2.\\033[0m Second step with \\033[1mimportant\\033[0m details
466551
\\033[36m3.\\033[0m Final configuration step
467552
===========================
468-
step 38
553+
step 41
469554
lua ProjectDIR/src/lmod.in.lua shell --regression_testing whatis markdown_content/2.0
470555
===========================
471556
markdown_content/2.0 : Name: Markdown Module
472557
markdown_content/2.0 : Version: 2.0
473558
markdown_content/2.0 : Description: Module demonstrating markdown help content
474559
===========================
475-
step 39
560+
step 42
476561
lua ProjectDIR/src/lmod.in.lua shell --regression_testing help markdown_with_images/1.0
477562
===========================
478563
Module Specific Help for "markdown_with_images/1.0"
@@ -484,7 +569,43 @@ This module demonstrates markdown with image support.
484569
\\033[36m[Image: Logo]\\033[0m (...)
485570
\\033[36m[Image: Screenshot]\\033[0m (...)
486571
\\033[1mFeatures\\033[0m
487-
\\033[36m•\\033[0m Feature one with **bold** text
488-
\\033[36m•\\033[0m Feature two with *italic* text
489-
\\033[36m•\\033[0m Feature three with `code` examples
572+
\\033[36m•\\033[0m Feature one with \\033[1mbold\\033[0m text
573+
\\033[36m•\\033[0m Feature two with \\033[3mitalic\\033[0m text
574+
\\033[36m•\\033[0m Feature three with \\033[2m\\033[36mcode\\033[0m examples
490575
For more information, visit the \\033[34m\\033[4mproject website\\033[0m (...).
576+
===========================
577+
step 43
578+
lua ProjectDIR/src/lmod.in.lua shell --regression_testing help nested_markdown_lists/1.0
579+
===========================
580+
Module Specific Help for "nested_markdown_lists/1.0"
581+
\\033[1m\\033[36mNESTED MARKDOWN IN LISTS\\033[0m
582+
\\033[1mOverview\\033[0m
583+
This module tests that nested markdown formatting (bold, italic, code) within list items is correctly processed and rendered.
584+
\\033[1mUnordered Lists with Nested Formatting\\033[0m
585+
\\033[36m•\\033[0m Feature with \\033[1mbold\\033[0m text
586+
\\033[36m•\\033[0m Feature with \\033[3mitalic\\033[0m text
587+
\\033[36m•\\033[0m Feature with \\033[2m\\033[36mcode\\033[0m examples
588+
\\033[36m•\\033[0m Feature with \\033[1mbold\\033[0m and \\033[3mitalic\\033[0m together
589+
\\033[36m•\\033[0m Feature with \\033[2m\\033[36mcode\\033[0m and \\033[1mbold\\033[0m text
590+
\\033[36m•\\033[0m Feature with a \\033[34m\\033[4mlink\\033[0m (...) inside
591+
\\033[1mOrdered Lists with Nested Formatting\\033[0m
592+
\\033[36m1.\\033[0m First item with \\033[1mbold\\033[0m emphasis
593+
\\033[36m2.\\033[0m Second item with \\033[3mitalic\\033[0m emphasis
594+
\\033[36m3.\\033[0m Third item with \\033[2m\\033[36mcode\\033[0m formatting
595+
\\033[36m4.\\033[0m Fourth item combining \\033[1mbold\\033[0m, \\033[3mitalic\\033[0m, and \\033[2m\\033[36mcode\\033[0m
596+
\\033[36m5.\\033[0m Fifth item with a \\033[34m\\033[4mlink\\033[0m (...) and \\033[1mbold\\033[0m text
597+
\\033[1mMixed Nested Formatting\\033[0m
598+
\\033[36m•\\033[0m Regular text without formatting
599+
\\033[36m•\\033[0m Text with \\033[1mbold\\033[0m only
600+
\\033[36m•\\033[0m Text with \\033[3mitalic\\033[0m only
601+
\\033[36m•\\033[0m Text with \\033[2m\\033[36mcode\\033[0m only
602+
\\033[36m•\\033[0m Text with \\033[1mbold\\033[0m and \\033[3mitalic\\033[0m combined
603+
\\033[36m•\\033[0m Text with all three: \\033[1mbold\\033[0m, \\033[3mitalic\\033[0m, and \\033[2m\\033[36mcode\\033[0m
604+
\\033[36m•\\033[0m Text with \\033[34m\\033[4mlinks\\033[0m (...) and \\033[1mbold\\033[0m formatting
605+
\\033[1mExpected Behavior\\033[0m
606+
All nested formatting should be rendered correctly:
607+
\\033[36m•\\033[0m \\033[1mBold\\033[0m text should appear bold
608+
\\033[36m•\\033[0m \\033[3mItalic\\033[0m text should appear italic
609+
\\033[36m•\\033[0m \\033[2m\\033[36mCode\\033[0m should appear with code formatting
610+
\\033[36m•\\033[0m \\033[34m\\033[4mLinks\\033[0m (...) should be formatted as links
611+
If you see raw markdown syntax (like \\033[2m\\033[36m\\033[1mbold\\033[0m\\033[0m or \\033[2m\\033[36m\\033[3mitalic\\033[0m\\033[0m) in the output, the nested formatting is not being processed correctly.

rt/markdown/markdown.tdesc

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,21 @@ testdescript = {
9595
runLmod show markdown_with_images/1.0 # 35
9696
runLmod whatis markdown_with_images/1.0 # 36
9797
98+
# Test nested markdown formatting in list items (SHOULD process nested formatting)
99+
runLmod help nested_markdown_lists/1.0 # 37
100+
runLmod show nested_markdown_lists/1.0 # 38
101+
runLmod whatis nested_markdown_lists/1.0 # 39
102+
98103
# ============================================================
99104
# Color support tests
100105
# ============================================================
101106
102107
# Test with color enabled
103108
export LMOD_COLORIZE=YES
104-
runLmod help markdown_content/2.0 # 37
105-
runLmod whatis markdown_content/2.0 # 38
106-
runLmod help markdown_with_images/1.0 # 39
109+
runLmod help markdown_content/2.0 # 40
110+
runLmod whatis markdown_content/2.0 # 41
111+
runLmod help markdown_with_images/1.0 # 42
112+
runLmod help nested_markdown_lists/1.0 # 43
107113
unset LMOD_COLORIZE
108114
109115
HOME=$ORIG_HOME
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
-- Module with nested markdown formatting in list items (SHOULD be processed correctly)
2+
help([[
3+
# Nested Markdown in Lists
4+
5+
## Overview
6+
This module tests that nested markdown formatting (bold, italic, code) within list items is correctly processed and rendered.
7+
8+
## Unordered Lists with Nested Formatting
9+
10+
- Feature with **bold** text
11+
- Feature with *italic* text
12+
- Feature with `code` examples
13+
- Feature with **bold** and *italic* together
14+
- Feature with `code` and **bold** text
15+
- Feature with a [link](https://example.com) inside
16+
17+
## Ordered Lists with Nested Formatting
18+
19+
1. First item with **bold** emphasis
20+
2. Second item with *italic* emphasis
21+
3. Third item with `code` formatting
22+
4. Fourth item combining **bold**, *italic*, and `code`
23+
5. Fifth item with a [link](https://example.com) and **bold** text
24+
25+
## Mixed Nested Formatting
26+
27+
- Regular text without formatting
28+
- Text with **bold** only
29+
- Text with *italic* only
30+
- Text with `code` only
31+
- Text with **bold** and *italic* combined
32+
- Text with all three: **bold**, *italic*, and `code`
33+
- Text with [links](https://example.com) and **bold** formatting
34+
35+
## Expected Behavior
36+
37+
All nested formatting should be rendered correctly:
38+
- **Bold** text should appear bold
39+
- *Italic* text should appear italic
40+
- `Code` should appear with code formatting
41+
- [Links](https://example.com) should be formatted as links
42+
43+
If you see raw markdown syntax (like `**bold**` or `*italic*`) in the output, the nested formatting is not being processed correctly.
44+
]])
45+
46+
whatis("Name: Nested Markdown Lists Test")
47+
whatis("Version: 1.0")
48+
whatis("Description: Tests nested markdown formatting within list items")
49+
50+
setenv("NESTED_MARKDOWN_LISTS_VERSION", "1.0")
51+

rt/markdown/out.txt

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,25 +290,57 @@ _ModuleTable_='_ModuleTable_={MTversion=3,depthT={},family={},mT={},mpathA={"Pro
290290
export _ModuleTable_;
291291
===========================
292292
step 37
293-
lua ProjectDIR/src/lmod.in.lua shell --regression_testing help markdown_content/2.0
293+
lua ProjectDIR/src/lmod.in.lua shell --regression_testing help nested_markdown_lists/1.0
294294
===========================
295295
MODULEPATH=ProjectDIR/rt/markdown/mf/Core;
296296
export MODULEPATH;
297297
_ModuleTable_='_ModuleTable_={MTversion=3,depthT={},family={},mT={},mpathA={"ProjectDIR/rt/markdown/mf/Core",},systemBaseMPATH="ProjectDIR/rt/markdown/mf/Core",}';
298298
export _ModuleTable_;
299299
===========================
300300
step 38
301-
lua ProjectDIR/src/lmod.in.lua shell --regression_testing whatis markdown_content/2.0
301+
lua ProjectDIR/src/lmod.in.lua shell --regression_testing show nested_markdown_lists/1.0
302302
===========================
303303
MODULEPATH=ProjectDIR/rt/markdown/mf/Core;
304304
export MODULEPATH;
305305
_ModuleTable_='_ModuleTable_={MTversion=3,depthT={},family={},mT={},mpathA={"ProjectDIR/rt/markdown/mf/Core",},systemBaseMPATH="ProjectDIR/rt/markdown/mf/Core",}';
306306
export _ModuleTable_;
307307
===========================
308308
step 39
309+
lua ProjectDIR/src/lmod.in.lua shell --regression_testing whatis nested_markdown_lists/1.0
310+
===========================
311+
MODULEPATH=ProjectDIR/rt/markdown/mf/Core;
312+
export MODULEPATH;
313+
_ModuleTable_='_ModuleTable_={MTversion=3,depthT={},family={},mT={},mpathA={"ProjectDIR/rt/markdown/mf/Core",},systemBaseMPATH="ProjectDIR/rt/markdown/mf/Core",}';
314+
export _ModuleTable_;
315+
===========================
316+
step 40
317+
lua ProjectDIR/src/lmod.in.lua shell --regression_testing help markdown_content/2.0
318+
===========================
319+
MODULEPATH=ProjectDIR/rt/markdown/mf/Core;
320+
export MODULEPATH;
321+
_ModuleTable_='_ModuleTable_={MTversion=3,depthT={},family={},mT={},mpathA={"ProjectDIR/rt/markdown/mf/Core",},systemBaseMPATH="ProjectDIR/rt/markdown/mf/Core",}';
322+
export _ModuleTable_;
323+
===========================
324+
step 41
325+
lua ProjectDIR/src/lmod.in.lua shell --regression_testing whatis markdown_content/2.0
326+
===========================
327+
MODULEPATH=ProjectDIR/rt/markdown/mf/Core;
328+
export MODULEPATH;
329+
_ModuleTable_='_ModuleTable_={MTversion=3,depthT={},family={},mT={},mpathA={"ProjectDIR/rt/markdown/mf/Core",},systemBaseMPATH="ProjectDIR/rt/markdown/mf/Core",}';
330+
export _ModuleTable_;
331+
===========================
332+
step 42
309333
lua ProjectDIR/src/lmod.in.lua shell --regression_testing help markdown_with_images/1.0
310334
===========================
311335
MODULEPATH=ProjectDIR/rt/markdown/mf/Core;
312336
export MODULEPATH;
313337
_ModuleTable_='_ModuleTable_={MTversion=3,depthT={},family={},mT={},mpathA={"ProjectDIR/rt/markdown/mf/Core",},systemBaseMPATH="ProjectDIR/rt/markdown/mf/Core",}';
314338
export _ModuleTable_;
339+
===========================
340+
step 43
341+
lua ProjectDIR/src/lmod.in.lua shell --regression_testing help nested_markdown_lists/1.0
342+
===========================
343+
MODULEPATH=ProjectDIR/rt/markdown/mf/Core;
344+
export MODULEPATH;
345+
_ModuleTable_='_ModuleTable_={MTversion=3,depthT={},family={},mT={},mpathA={"ProjectDIR/rt/markdown/mf/Core",},systemBaseMPATH="ProjectDIR/rt/markdown/mf/Core",}';
346+
export _ModuleTable_;

src/MarkdownProcessor.lua

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,13 +284,27 @@ local function processListItem(line)
284284
-- Unordered lists
285285
local indent, marker, content = line:match("^(%s*)([-*+])%s+(.+)$")
286286
if indent and marker and content then
287+
-- Process inline formatting in the content
288+
-- Process images before links to avoid pattern conflicts
289+
content = processInlineCode(content)
290+
content = processEmphasis(content)
291+
content = processImages(content)
292+
content = processLinks(content)
293+
287294
local bullet = USE_COLOR and applyFormat("", ANSI.CYAN) or ""
288295
return indent .. bullet .. " " .. content
289296
end
290297

291298
-- Ordered lists
292299
indent, marker, content = line:match("^(%s*)(%d+%.)%s+(.+)$")
293300
if indent and marker and content then
301+
-- Process inline formatting in the content
302+
-- Process images before links to avoid pattern conflicts
303+
content = processInlineCode(content)
304+
content = processEmphasis(content)
305+
content = processImages(content)
306+
content = processLinks(content)
307+
294308
local numberedMarker = USE_COLOR and applyFormat(marker, ANSI.CYAN) or marker
295309
return indent .. numberedMarker .. " " .. content
296310
end

0 commit comments

Comments
 (0)