TerosTechnology / vscode-terosHDL

VHDL and Verilog/SV IDE: state machine viewer, linter, documentation, snippets... and more!
https://terostechnology.github.io/terosHDLdoc/
GNU General Public License v3.0
542 stars 45 forks source link

Markdown multiline code block displayed as single line #598

Closed SebastianHambura closed 4 weeks ago

SebastianHambura commented 5 months ago

Describe the bug In the documentation description, markdown multiline code blocks are displayed on a single line.

To Reproduce

//!
//! Vitis code snippet :
//! ``` C
//!    int* versions = 0x0080000000 ;
//!    xil_printf("FLAVOUR: %08x\n\r", versions[10]) ;
//!    xil_printf("GLOBAL_DATE: %08x\n\r", versions[9]) ;
//!    xil_printf("GLOBAL_TIME: %08x\n\r", versions[8]) ;
//!    xil_printf("GLOBAL_VER:  %08x\n\r", versions[7]) ;
//!    xil_printf("GLOBAL_SHA:  %08x\n\r", versions[6]) ;
//!    xil_printf("TOP_VER:     %08x\n\r", versions[5]) ;
//!    xil_printf("TOP_SHA:     %08x\n\r", versions[4]) ;
//!    xil_printf("CON_VER:     %08x\n\r", versions[3]) ;
//!    xil_printf("CON_SHA:     %08x\n\r", versions[2]) ;
//!    xil_printf("HOG_VER:     %08x\n\r", versions[1]) ;
//!    xil_printf("HOG_SHA:     %08x\n\r", versions[0]) ;
//! ```
//! Attempting to write to a register, or to read from a non-existant one crashes the software.
//! (and maybe even stalls the whole CPU, need to be tested)
//!
module axi_version_regs #()
endmodule

Please complete the following information:

Screenshots We get: grafik

I expected (taken from https://markdownlivepreview.com/): grafik

Additional Context As far as I know, for Markdown one quote ' -> code displayed on a single line and 3 quotes ''' -> code should be displayed on multiple lines

grafik

gmartina commented 5 months ago

Looks like this is a bug when converting markdown to html. Exported Markdown file works fine.

qarlosalberto commented 5 months ago

It's a pain but you need to insert empty lines:

//!
//! Vitis code snippet :
//!
//! ``` C
//!    int* versions = 0x0080000000 ;
//!
//!    xil_printf("FLAVOUR: %08x\n\r", versions[10]) ;
//!
//!    xil_printf("GLOBAL_DATE: %08x\n\r", versions[9]) ;
//!
//!    xil_printf("GLOBAL_TIME: %08x\n\r", versions[8]) ;
//! ```
//!
//! Attempting to write to a register, or to read from a non-existant one crashes the software.
//! (and maybe even stalls the whole CPU, need to be tested)
//!
qarlosalberto commented 5 months ago

I think that there is no way to do this. If we render the break line in the comments as a break line in the HTML this is really ugly, in this case it's not possible to split the big lines.

Other way it's only support break line in comments == break line in HTML for code snippets.

gmartina commented 5 months ago

i did a workaround in 3fef9842126125b00437d97e6e03079662036ff9

qarlosalberto commented 5 months ago

Look a good starting point, but I think that it doesn't work for all the cases. I see the problems:

  1. Depends of the language the comment symbol is -- (VHDL) or // (Verilog/SV).
  2. It's possible to configure the symbol: https://terostechnology.github.io/terosHDLdoc/docs/documenter/getting_started#configuration

Myabe it's better to iterate all the descriptions after the parsing and to do, before to convert to MarkDown:

code_fix = code.replace(/```[^]*```/g, function(match){return match.replace(/\n/g, ' \n');});

What do you think?

gmartina commented 5 months ago

Your are right, i totally forgot about the different comment symbol for verilog/sv. I will revisit this in a new PR.