Ways to write Pseudo Code in Asciidoc

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Ways to write Pseudo Code in Asciidoc

smitty4doc
Anyone have any suggestions on how to write Pseudo Code in Asciidoc?

I tried something like:

IF some condition::
     *Method* and it's description::::
else::
    Some other *Method* and it's description::::
EndIf

but this got ugly quick when the nesting started going deep and I needed deeper indentation (only 3 or 4 levels though).

I thought about using [source,pseudo], but this doesn't exist and it only helps in preserving indentation,
but I want to be able to bold some text in the pseudo code too.

This is not formal Pseudo code, I just want a good way to communicate some Logic to Business Analyst types that are not programmers and don't want to read code.

I ended up using Mermaid and creating a flowchart, but I would have preferred something simpler and am looking for ideas for ways I might incorporate nice looking Pseudo code into AsciiDoc.


Thanks,
Smitty

Reply | Threaded
Open this post in threaded view
|

Re: Ways to write Pseudo Code in Asciidoc

David Jencks
You can apply inline formatting in source blocks by specifying quotes substitution:

[source,subs=+quotes]
----
IF some condition::
*Method* and it's description::::
else::
Some other *Method* and it's description::::
EndIf
----
Is this what you’re looking for?

David Jencks

On Jan 27, 2021, at 7:18 PM, smitty4doc [via Asciidoctor :: Discussion] <[hidden email]> wrote:

Anyone have any suggestions on how to write Pseudo Code in Asciidoc?

I tried something like:

IF some condition::
     *Method* and it's description::::
else::
    Some other *Method* and it's description::::
EndIf

but this got ugly quick when the nesting started going deep and I needed deeper indentation (only 3 or 4 levels though).

I thought about using [source,pseudo], but this doesn't exist and it only helps in preserving indentation,
but I want to be able to bold some text in the pseudo code too.

This is not formal Pseudo code, I just want a good way to communicate some Logic to Business Analyst types that are not programmers and don't want to read code.

I ended up using Mermaid and creating a flowchart, but I would have preferred something simpler and am looking for ideas for ways I might incorporate nice looking Pseudo code into AsciiDoc.


Thanks,
Smitty




If you reply to this email, your message will be added to the discussion below:
https://discuss.asciidoctor.org/Ways-to-write-Pseudo-Code-in-Asciidoc-tp8464.html
To start a new topic under Asciidoctor :: Discussion, [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: Ways to write Pseudo Code in Asciidoc

smitty4doc
Thanks David,

This renders like this:

IF some condition::
     Method and it's description::::
else::
    Some other Method and it's description::::
EndIf

And it didn't bold the Method name and just removed the *'s.

Though you got me digging through the documentation with this clue and I did get it to work with this.

[subs="quotes"]
----
IF some condition
     *Method* and it's _description_
else::
    Some other *Method* and it's _description_
EndIf
----

thanks!!
Reply | Threaded
Open this post in threaded view
|

Re: Ways to write Pseudo Code in Asciidoc

mojavelinux
Administrator
You should almost never use just "quotes" alone for subs. If you want preformatted text, but still allow formatting and macros, then you should use

[subs=normal]

If you only need formatting (not macros), then you can use:

[subs="specialchars,quotes"]

Best Regards,

-Dan

On Sat, Jan 30, 2021 at 2:33 PM smitty4doc [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Thanks David,

This renders like this:

IF some condition::
     Method and it's description::::
else::
    Some other Method and it's description::::
EndIf

And it didn't bold the Method name and just removed the *'s.

Though you got me digging through the documentation with this clue and I did get it to work with this.

[subs="quotes"]
----
IF some condition
     *Method* and it's _description_
else::
    Some other *Method* and it's _description_
EndIf
----

thanks!!



If you reply to this email, your message will be added to the discussion below:
https://discuss.asciidoctor.org/Ways-to-write-Pseudo-Code-in-Asciidoc-tp8464p8477.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML


--
Dan Allen (he, him, his) | @mojavelinux | https://twitter.com/mojavelinux