Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Timmmm
Copy link
Collaborator

@Timmmm Timmmm commented Nov 25, 2025

When you have a substitution like {ge} in an inline node (which most of the tagged text is), then it wasn't being substituted when recorded in the JSON output because that substitution is applied at the block level.

@Timmmm Timmmm force-pushed the user/timh/substitute_macros branch from 0bbaff4 to 971d55e Compare November 25, 2025 18:28
@james-ball-qualcomm
Copy link
Collaborator

Your change to tags.rb is having a negative side effect. The regression test (just run "make") fails because some of the adoc formatting information is being removed. I want to see this so I can create the HTML equivalent.

11,13c11,13
<     "norm:superscript": "xyz 2^32^ 123",
<     "norm:subscript": "xyz X~i~ 123",
---
>     "norm:superscript": "xyz 232 123",
>     "norm:subscript": "xyz Xi 123",

I also added this diagnostic puts to your tags.rb and added another case to test.adoc to check macro replacement in paragraph (i.e. [[foo]]) anchors. Looks like the macros aren't replaced in paragraph tags.

tags.rb change:

        if node.text.nil?
          nil
        else
          out = node.apply_subs(node.text, node.parent.instance_variable_get(:@subs))
          puts("XXX: in='#{node.text}' out='#{out}'") if out != node.text
          out
        end

test.adoc change:

Original

Macro call [#norm:macro_call]#200 {ge} 100# outside.

Change

Inline macro call [#norm:inline_macro_call]#200 {ge} 100# outside.

Paragraph macro call [#norm:paragraph_macro_call]#10 {ge} 10# outside.

Output from diagnostic puts:

XXX: in='xyz 2^32^ 123' out='xyz 232 123'
XXX: in='xyz X~i~ 123' out='xyz Xi 123'
XXX: in='ABC [.underline]#inside tag# GHI' out='ABC inside tag GHI'
XXX: in='200 {ge} 100' out='200 &#8805; 100'

You can see:

  • Subscript & superscript formatting is being removed (bad)
  • Underline formatting is being removed (bad)
  • "ge" macro is being expanded in inline tag (good)
  • "ge" macro is NOT being expanded in the paragraph tag (bad)

@Timmmm
Copy link
Collaborator Author

Timmmm commented Nov 25, 2025

Interesting, thanks for testing - I'll take another look.

@james-ball-qualcomm
Copy link
Collaborator

james-ball-qualcomm commented Nov 25, 2025 via email

@Timmmm
Copy link
Collaborator Author

Timmmm commented Nov 26, 2025

Any idea how?

@james-ball-qualcomm
Copy link
Collaborator

Instead of calling node.apply_subs(node.text, node.parent.instance_variable_get(:@subs)), which passes in an array of substitution functions from the parent, could you just pass in a reference to just the macro substitution function?

If you omit the subs parameter to apply_subs(), it defaults to NORMAL_SUBS (see screenshot below). The NORMAL_SUBS is an array of function references and includes "macros" but also others we don't want. So, could you just pass in a reference to the "macros" function?

image

@james-ball-qualcomm
Copy link
Collaborator

BTW, even if you can just get macro substitution to work, its only working in inline tags ([#foo]#...# syntax). How can we get it to work for the paragraph tags ([[foo]]) too?

@james-ball-qualcomm
Copy link
Collaborator

@Timmmm, any update on this?

@Timmmm
Copy link
Collaborator Author

Timmmm commented Dec 8, 2025

Hey, sorry - slightly fell off my radar. I'll take another look.

@james-ball-qualcomm
Copy link
Collaborator

james-ball-qualcomm commented Dec 8, 2025 via email

@james-ball-qualcomm
Copy link
Collaborator

@Timmmm, I see that the upstream ISA manual now has macros everywhere instead of using Unicode characters or Unicode codes. Looks like you might have been working with @aswaterman on the change. This raises the priority of getting this PR fixed since now the normative rules won't show the intended Unicode characters (just the macro name).

@james-ball-qualcomm
Copy link
Collaborator

I've merged in the upstream ISA manual repo and resolved about a dozen conflicting files. However, our normative rules are now somewhat broken due to the use of the macros. Can we get this fixed before someone notices and complains?

@Timmmm Timmmm force-pushed the user/timh/substitute_macros branch 2 times, most recently from 99ffed6 to 0559e94 Compare December 11, 2025 10:00
@Timmmm
Copy link
Collaborator Author

Timmmm commented Dec 11, 2025

Ok it seems the loss of bold/italic etc was a separate issue to substitutions. Those things get converted to inline_quoted nodes and we weren't outputting any formatting characters for them based on their type.

This seems to work now but maybe double check!

@james-ball-qualcomm
Copy link
Collaborator

I'm not clear from your comments about bold & italics. Can we add those?

@Timmmm
Copy link
Collaborator Author

Timmmm commented Dec 11, 2025

Yeah they should work.

When you have a substitution like `{ge}` in an inline node (which most of the tagged text is), then it wasn't being substituted when recorded in the JSON output because that substitution is applied at the block level.

Signed-off-by: Tim Hutt <[email protected]>
For things like `*bold*` and `_italic_` text they get converted to `inline_quoted` nodes with a `@type` member. We need to use these to surround the text with something to indicate they are bold/italic.

I went with the Asciidoctor syntax, though this choice is fairly arbitrary.

Signed-off-by: Tim Hutt <[email protected]>
@Timmmm Timmmm force-pushed the user/timh/substitute_macros branch from 0559e94 to e681bb1 Compare December 17, 2025 18:40
@Timmmm
Copy link
Collaborator Author

Timmmm commented Dec 17, 2025

Ok I think all the feedback is addressed now.

@james-ball-qualcomm james-ball-qualcomm merged commit 4e6b9d0 into riscv:main Dec 17, 2025
2 checks passed
@Timmmm Timmmm deleted the user/timh/substitute_macros branch December 18, 2025 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants