restructuredText inline literal that can wrap to the next line (for PDF output) - literals

I am using restructuredText to create a report which includes tom log file outputs.
What I have is a number of sections with numbered lists of literals.
This looks like this:
#. ``some log file output``
#. ``more output``
Now the problem with this is that when I convert to a PDF from this using rst2pdf, the literals can sometimes be quite long and flow off the page.
What I would love is away to mark a section of text as a code literal that can flow onto the next line just like regular text.
I want this because if I don't mark the log file output as being a literal, there is sometimes some crud within the log file output which rst is interpreting as inline markup or other rst related commands.
Any other suggestions as to how this can be best done?
I know that I could ensure that the source rst file only has lines of a certain width but this would make the source file look horrible and make it unwieldy to edit.
I have tried the following 2 things, both of which don't help:
I found a rst2pdf option:
--fit-literal-mode=MODE
What to do when a literal is too wide.
One of error,overflow,shrink,truncate.
Default="shrink"
After some researching, I found mention of a wrapping option for literals.
I got rst2pdf to dump out the default stylesheet using:
rst2pdf --print-stylesheet which I then saved and modified such that the wordWrap option under literal was changed to CJK.

Related

In synopsys VCS, how can I get the raw RTL verilog output file?

I need the VCS preprocessor output. Theres a way to get a verilog file where all params and macros are filled in from the preprocessor. How do I do that?
I found an answer online. vppreproc command will flatten all macros/defines.
https://metacpan.org/pod/distribution/Verilog-Perl/vppreproc
In vcs you can use the -Xman=28 qualifier. It will generate a token file with expanded macros.
From the manual:
Produces a mangled version of input, changing variable names to words from list. Useful to get an entire Verilog design into a single file. Output is saved in the tokens.v file. You can substitute -Xman for -Xmangle.
The argument number can be 1, 4, 12, or 28:
-Xman=1
Randomly changes names and identifiers, and removes comments, to provide more secure code.
-Xman=4
Preserves variable names, but removes comments.
-Xman=12
Does the same thing as -Xman=4, but also enters, in comments, the original source file name and the line number of each module header.
-Xman=28
Does the same thing as -Xman=12, but also writes at the bottom of the file comprehensive statistics about the contents of the original source file.

Data structure for a grammar checker for LaTeX sources

Let me start with acknowledging that this is a rather broad question, but I need to start somewhere and reduce the design space a bit.
The problem
Grammarly is an online app that provides grammar and spell-checking as a browser plugin. Currently, there neither exists support for text editors nor latex sources. Grammarly is apparently often confused when forced to deal with annotated text or text that is formatted (e.g. contains wrapped lines). I guess many people could use that tool when writing up scientific papers or pretty much any other LaTeX tool. I also presume that other solutions exist or will soon pop up that work similarly.
The solution
In principle, it is not necessary to support Grammarly directly in, e.g., emacs. It suffices to provide a convenient interface to check multiple source files at once. To that end, a simple web app could walk through a directory, read all .tex sources, remove all formatting and markup, and expose the files as an HTML document. The user could open that document, run Grammarly, and apply any fixes. The app would have to take the corrected text and reapply formatting, markdown, etc. to save the now fixed source file.
The question(s)
While it is reasonably simple to create such a web application, there are other requirements to be considered: LaTeX parsing (up to "standard" syntax) and a library like HaTeX could deal with parsing and interpretation. But the process of editing needs some thought. Presuming that the removal of formatting can be implemented by only deleting content, it should be possible to take a correction as a diff and reapply it to the formatted document.
In Haskell, is there a data structure for text editing that supports this use case. That is, a representation of text that can store deletions, find diffs, undo deletions, and move a diff accordingly? If not in Haskell, does something like this exist somewhere else?
Bonus question 2: What is the simplest (as in loc required) web framework in Haskell to set up such a web app? It would serve one HTML document and accept updated versions of the text files. No database is required.
Instead of removing and then adding the text formatting, you could parse the souce text into a stream of annotated tokens:
data AnnotatedChar = AC
{ char :: Char
, formatting :: String
}
The following source:
Is \emph{good}.
would be parsed as:
[AC 'I' "", AC 's' "", AC ' ' "\emph{", AC 'g' "", ...
Then, extract only the chars from this list, send them to Grammarly, and get back the result. Now, diff the list of annotated characters with the list of characters you got from Grammarly. This way, you only to deal with a list of characters, but keep the annotations.

why % sign used in pdf strcuture

I have one question regarding the pdf structure, why % sign is used in pdf.
I got some results where they mentioned % sign is used for comments but if we use % sign for comments then what about % sign used in %PDF-1.5 and %%EOF?
%PDF-1.5 which defines the header of the file and
%%EOF which defines the end of the pdf structure.
then why is the % sign used for PDF-1.5 and why is the % sign used 2 times in EOF?
From the results I knew that % sign is used for comments, so why it is different for above two terms?
Your help will be appreciated - Thank you
I actually know nothing about pdf structure or using % correctly, but it seems to have the same reasons as the shebang #! followed by an executable is required in shell scripts, like bash, perl, or even python.
More can be read at this stack overflow answer here for why bash scripts need the #! at the beginning of scripts: https://stackoverflow.com/a/8968514/6037755
why is the % sign used for PDF-1.5 and why is the % sign used 2 times in EOF?
From the results I knew that % sign is used for comments, so why it is different for above two terms?
You can consider those entries actually to be comments (after all they do not contain any PDF objects as such to use for PDF rendering) which you are required to put at certain positions of a PDF file.
According to the specification ISO 32000-1:
7.5.2 File Header
The first line of a PDF file shall be a header consisting of the 5 characters %PDF– followed by a version number of the form 1.N, where N is a digit between 0 and 7.
and
7.5.5 File Trailer
The trailer of a PDF file enables a conforming reader to quickly find the cross-reference table and certain special objects. Conforming readers should read a PDF file from its end. The last line of the file shall contain only the end-of-file marker, %%EOF.
As the use of "shall" here indicates, these are requirements.
And it indeed makes sense that these markers in all other respects are comments.
Only for the purpose of identifying the start and the end of a PDF these markers have a special meaning, before a PDF processor starts working with actual PDF objects. As soon as start and end are identified, these markers have to be ignored. So, making these markers comments is an obvious choice.
This is true for unusual processing types, too. E.g. if for some reason the cross references of a PDF are broken and some program tries to re-create them by searching for indirect PDF objects, it does not need to specially treat these markers, it automatically ignores them as comments.
PS According to Adobe's Implementation Notes in the Annex H of their PDF Reference, their tools also accept an alternative header:
3.4.1, “File Header”
[...]
14.Acrobat viewers also accept a header of the form
%!PS−Adobe−N.n PDF−M.m
If you want to find out why the marker comment contents were chosen exactly like they they are, therefore, you should look into the history of PDF and Postscript

filetype and corresponding program that will honor control characters

I am using Node.js to write to log files, using the colors module which I believe inserts control characters into strings, for coloring/text formatting which will display in a terminal application.
When I write to the terminal directly, it shows colors, but when I write to a .log file and then tail the log file with either Terminal.app or iterm2, it does not show colors/text formatting. Does anybody know why this is? My guess is that when you write to the log file the control characters don't get saved? In that way, when tailing they won't display at all?
Perhaps if I write to .txt file or some other type of file, the control characters will remain?
How does this work exactly? At some point the control characters are getting stripped or ignored and I am not sure how or when.
See this code.
It checks if the output is going to a terminal (by checking process.stdout.isTTY) or to somewhere else, like a file. If the latter, no color codes are outputted.

VBA how to run a string as a line of code

Is there a way to convert a string into an executable line of code?
something like:
Dim Line1 as String
Line1 = "MsgBox (""Hello"")"
Execute Line1
resulting in the pop up box saying Hello.
What I'm doing is pulling lines out of a text file. I can pull lines that are the names of form controls and use them to perform actions on those form controls but I'd like to go one step further and execute lines.
I've seen claims that this would work:
Application.Run Line1
or make the variable an array and store it in element 1 e.g. and use
Application.Run Line1(1)
but it doesn't work for me.
Ok, while writing this I've also been experimenting. I found that
Eval (Line1)
will work when Line1 is a message box, but not when it is something like:
line1 = "DoCmd.OpenForm ""form1"""
Any tips would be appreciated.
Thanks
You can use,
Eval("DoCmd.OpenForm(""form1"")")
You have to make sure any functions you include use parentheses.
Further reference,
http://msdn.microsoft.com/en-us/library/office/aa172212(v=office.11).aspx
It's not exactly what I was asking, I ended up going a slightly different direction, but here's what I ended up doing and it would probably be easily altered to more closely match my question. I actually took lines of text from an external text file and inserted them into a line of code. What I was doing in this example was just hiding columns, the external text file was a list of column names. (figuring out how to output that was fun too)
Open "C:\UserList.txt" For Input As #TextFile
While Not EOF(TextFile)
Line Input #TextFile, TextLine
Screen.ActiveDatasheet.Controls(TextLine).ColumnHidden = True
Wend
Visual Basic is a compiler language, and as such does not support the ability to execute human-readable code while it is running. All code written in VBA must first be compiled BEFORE the program runs the first time.
However, SQL is an interpreter language, and can be handed code which it will execute line by line. You can also fetch contents for variables from other sources while the program runs, you just can't build a string while the program is running and then execute it in VBA directly.

Resources