Can I write doxygen alias similar to #code or #verbatim? - doxygen

I need an alias to mark command-line code, set on a black background with white text, to be used like this:
#cmd
C:\temp>echo Hello, world!
Hello, world!
C:\temp>
#endcmd
Ordinary doxygen's aliases can't do this (multiline, nested "\temp"), but #code and #verbatim can. However, I can't use them because they are formatted as a white background with black text, so overwriting pre.fragment class with a custom CSS is not correct.
Any ideas?
UPD:
Comments showed how bad my English is...
Well, try again. Regular doxygen's features like HTML and XML works as shown bellow:
cpp file doxygen produced index.html
/**
#mainpage main |
<pre> | <pre>C:>echo Hello, world!
C:\temp>echo Hello, world! | Hello, world!</pre>
Hello, world! |
|
C:\temp> | <pre>C:></pre>
</pre> |
*/ |
in the log:
/tmp/index.h:3: warning: Found unknown command `\temp'
/tmp/index.h:6: warning: Found unknown command `\temp'
"code" and "verbatim" works different! Feel the difference:
cpp file doxygen produced index.html
/**
#mainpage main |
#verbatim | <div class="fragment">
C:\temp>echo Hello, world! | <pre class="fragment">C:\temp>echo Hello, world!
Hello, world! | Hello, world!
|
C:\temp> | C:\temp>
#endverbatim | </pre>
*/ | <div>
The question is: Can I write alias, that will work like "code" or "verbatim". Is it clean now?

What about just using and HTML div with your own CSS markup added to the Doxygen css file. It seems about the same amount of typing.

This answer summarises some the the comments in Paul Joireman's answer.
Paul Joireman's answer is the way to go. Define two aliases in your doxygen configuration file:
ALIASES += "mycode=<div class="myfragment"><pre class=myfragment>"
ALIASES += "endmycode=</pre></div>"
and the wrap your code example in \mycode and \endmycode statements. For example, your C++ file could look something like
/** \mainpage main
* \mycode
* C:\\temp>echo Hello, World!
* Hello, World!
*
* \endmycode
*/
which yields the following corresponding doxygen HTML output:
<div class="myfragment>"><pre class="myfragment>">
C:\temp>echo Hello, World!
Hello, World!</pre></div>
(I'm not sure why there are >'s in the class="myfragments>" parts). You will need to format the myfragments class in the CSS file.
The one additional thing in the above C++ code that wasn't mentioned in the comments is the use of the escaped backslash \\ in the code example.

The only wayout i found is
ALIASES += cmd="<div class=\"cmd\">#verbatim"
ALIASES += endcmd="#endverbatim</div>"
Where, CSS "cmd" class is set in your own stylesheet. May be:
.cmd { color:#e3e3e3; background-color:#222222; }

Related

How to write in two columns like a table in Linux man pages?

I'm creating a custom man page for my C library, and I'd like to do a thing like this
LIST OF FUNCTIONS |<--- terminal window side
|
Function Description |
function1 function1's description |
function2 function2's description |
which is longer than the |<--- here if the text
first one | overlaps out of the window,
function3 function3's description | it auto-aligns to Description
... ... |
How could I do that?
I think that it's a combination of https://tldp.org/HOWTO/Man-Page/q3.html and then use GROFF - https://www.linuxjournal.com/article/1158
.SH DESCRIPTION
.B foo
frobnicates the bar library by tweaking internal
symbol tables. By default it parses all baz segments
and rearranges them in reverse order by time for the
.BR xyzzy (1)
linker to find them. The symdef entry is then compressed
using the WBG (Whiz-Bang-Gizmo) algorithm.
All files are processed in the order specified.
There is a command on the linuxjournal site with the following:
$ groff -Tascii -man coffee.man | more
The groff man page starts with the following:
The man macro package for groff is used to produce manual pages
(“man pages”) like the one you are reading.

how do I prepend a string to stdin in the command line?

This is probably pretty basic, but I'm struggling with the command line. Suppose I want to turn a markdown file myDoc.md to a pdf file. Markedjs provides a command line tool to convert markdown to html, and wkhtmltopdf can convert html to pdf, so I have the command
marked myDoc.md | wkhtmltopdf - myDoc.pdf
That works, it generates the pdf. But the pdf is pretty ugly, I want to prepend a style section to the html before passing it to wkhtmltopdf. Yes I could put the style section in the markdown document, but I don't want to pollute the markup with this. I want to use marked to generate html, then prepend a style section, then feed that to wkhtmltopdf, without any intermediate files to clean up. Something like this pseudo code
myStyle="<style>
*{
font-family: arial;
}
h1{
text-align:center;
}
</style>"
marked myDoc.md | concatenatestrings myStyle - | wkhtmltopdf - myDoc.pdf
but where I'm having trouble is I don't know how to handle the multiline string for myStyle and finding something that does what the hypothetical concatenatestrings command does, taking a string from stdin, prepend myStyle, and output to stdout.
I would use a template file, then use a subshell to output the template and output of marked myDoc.md to stdout, then pipe the results to the rest of your chain.
So, let us create the template file...
template.html
<style>
*{
font-family: arial;
}
h1{
text-align:center;
}
</style>
...and use it
$ (cat template.html && marked myDoc.md) | wkhtmltopdf - myDoc.pdf
I haven't tested this with your command (I don't want to install marked just to test it), but have tested it with the following...
$ (echo ree && echo cola) | cat
ree
cola

Non-latin symbols in chapter title

I have the following asciidoc source file:
:doctype: book
Перший розділ
-----------------
Chapters can contain sub-sections nested up to three deep.
The following error comes up:
asciidoctor: WARNING: b.txt: line 3: unterminated listing block
M+ 1mn is not a known font.
I run it with the following command:
asciidoctor -r asciidoctor-pdf -b pdf b.txt -a pdf-style=my.yml -a pdf-fontsdir="/usr/share/fonts/truetype/msttcorefonts"
Where my.yml has this content:
extends: default
font:
catalog:
Times_New_Roman:
normal: Times_New_Roman.ttf
bold: Times_New_Roman_Bold.ttf
italic: Times_New_Roman_Italic.ttf
bold_italic: Times_New_Roman_Bold_Italic.ttf
base:
font-family: Times_New_Roman
Apparently, the problem is in Ukrainian symbols. How should I fix it?
EDIT:
This happens only if the chapter title is in Cyrillic, with the body it works fine.
:doctype: book
The First Chapter
-----------------
Розділи можуть містити підрозділи.
I think the problem is that you are using 4 extra dashes in the document title.
Перший розділ
-----------------
It should be:
Перший розділ
-------------
Please note that setext (two-lines) titles are not recommended, instead you should use this syntax:
= Перший розділ
:doctype: book
Chapters can contain sub-sections nested up to three deep.

How to generate caption from img alt atribute

Is there a way to convert an img tag containing an alt attribute (in a html file),
<img src="pics/01.png" alt="my very first pic"/>
to an image link plus caption (org file),
#+CAPTION: my very first pic
[[pics/01.png]]
using pandoc?
I'm calling pandoc like this:
$ pandoc -s -r html index.html -o index.org
where index.html contains the img tag from above, but it doesn't add the caption in the output org file:
[[pics/01.png]]
Currently the Org Writer unfortunately throws away the image alt and title strings. Feel free to submit an issue or patch if there's a way to do alt text in Org.
You can also always write a filter to modify the doc AST and add the alt text to an additional paragraph.
OP here. I didn't manage to make pandoc bend to my needs in this case. But a little bash scripting with some awk help does the trick.
The script replaces all img tags with org-mode equivalents plus captions. Pandoc leaves these alone when converting from html to org-mode.
The awk script,
# replace_img.awk
#
# Sample input:
# <img src="/pics/01.png" alt="my very first pic"/>
# Sample output:
# #+CAPTION: my very first pic
# [[/pics/01.png]]
BEGIN {
# Split the input at "
FS = "\""
}
# Replace all img tags with an org-mode equivalent.
/^<img src/{
print "#+CAPTION: " $4
print "[["$2"]]"
}
# Leave the rest of the file intact.
!/^<img src/
and the bash script,
# replace_img.sh
php_files=`find -name "*.php"`
for file in $php_files; do
awk -f replace_img.awk $file > tmp && mv tmp $file
done
Place these files at the root of the project, chomod +x replace_img.sh and then run the script: ./replace_img.sh. Change the extension of the files, if needed. I've had over 300 php files.

doxygen: how to output backticks in a code section

i was wondering if it is possible to output backticks whithin a doxygen' code section.
~~~~~~~~~~
for file in `ls dir/*.filter`
do
done
~~~~~~~~~~
I get no output at all. And this seems to be caused by the backtick "`" i've inserted into my code section.
Does anyone had the same issue. Any suggestion?
many thanks
` is used to create an inline code block. Instead, use \code, \endcode rather than a markdown code block.
for example
\code
this is an inline `code block with ` characters
\endcode
renders with the ` characters included.
When a pair of `s is encountered in the code, doxygen will not process whatever is between.
The following will render correctly:
\code
for file in `ls dir/*.filter`
do
done
\endcode