diff --git a/src/asciidoc/templates/Listing.tsx b/src/asciidoc/templates/Listing.tsx index c66263c..8cf47db 100644 --- a/src/asciidoc/templates/Listing.tsx +++ b/src/asciidoc/templates/Listing.tsx @@ -7,7 +7,6 @@ const Listing = ({ node }: { node: LiteralBlock }) => { const { document } = useConverterContext() const docAttrs = document.attributes || {} - const nowrap = node.attributes.nowrap || docAttrs['prewrap'] === undefined if (node.style === 'source') { const lang = node.language @@ -19,7 +18,7 @@ const Listing = ({ node }: { node: LiteralBlock }) => { > <div className="content"> - <pre className={cn('highlight', nowrap ? ' nowrap' : '')}> + <pre className={cn('highlight', node.noWrap ? ' nowrap' : '')}> {lang ? ( <code className={lang ? `language-${lang}` : ''} @@ -45,10 +44,8 @@ const Listing = ({ node }: { node: LiteralBlock }) => { <Title text={node.title} /> <div className="content"> <pre - className={cn('highlight !block', nowrap ? 'nowrap' : '')} - dangerouslySetInnerHTML={{ - __html: node.content || '', - }} + className={cn('highlight !block', node.noWrap ? 'nowrap' : '')} + dangerouslySetInnerHTML={{ __html: node.content || '' }} /> </div> </div> diff --git a/src/asciidoc/utils/prepareDocument.ts b/src/asciidoc/utils/prepareDocument.ts index d28d17b..3cea0b9 100644 --- a/src/asciidoc/utils/prepareDocument.ts +++ b/src/asciidoc/utils/prepareDocument.ts @@ -147,6 +147,8 @@ export interface LiteralBlock extends BaseBlock { type: 'listing' source: string language: string | undefined + decodedContent: string + noWrap: boolean } export interface SectionBlock extends BaseBlock { @@ -325,14 +327,13 @@ export const prepareDocument = (document: AdocTypes.Document) => { } if (type === 'listing' || type === 'literal') { + const listingBlock = processedBlock as LiteralBlock if ('getSource' in block) { - const listingBlock = processedBlock as LiteralBlock listingBlock.source = block.getSource() - listingBlock.language = block.getAttribute('language') - listingBlock.content = listingBlock.content - ? decode(listingBlock.content) - : undefined } + listingBlock.noWrap = block.isOption('nowrap') + listingBlock.language = block.getAttribute('language') + listingBlock.decodedContent = decode(listingBlock.content) } if (type === 'section') { diff --git a/src/examples/listing.js b/src/examples/listing.js index e3b0285..0db49bc 100644 --- a/src/examples/listing.js +++ b/src/examples/listing.js @@ -67,6 +67,11 @@ public class ApplicationConfigurationProvider extends HttpConfigurationProvider } } ---- + +// html tags +---- +MPN1:<MFG>:<PN>:<REV>:<SERIAL> +---- ` export default listing