pwndoc icon indicating copy to clipboard operation
pwndoc copied to clipboard

Styling Code Snippets & Command Output

Open nitek29 opened this issue 2 years ago • 10 comments

Hey,

It will be great if we can somehow mark/style parts of text in a command output or source snippet so they can stand out. Ideally, we can either bold them, change their color, or distinguish them in another way. The problem is that it is not possible to format the text in the code and code block styles in the UI. For example, highlighting the vulnerable header in an HTTP request. It's not a question of style functionnality in the .docx template. Whatever is easier to implement, I am sure we can get it to work.

Thanks!

nitek29 avatar Jul 11 '22 08:07 nitek29

This is because code blocks in the application will result in a specific style in Word document. It would be possible to add syntax highlighting in the application but it won't be added in the generated report. So to be coherent between both the application and the report it was not added.

yeln4ts avatar Jul 19 '22 13:07 yeln4ts

Thank for your reply. In this case, is it not possible to update the style in Word document too ?

nitek29 avatar Jul 21 '22 13:07 nitek29

I did not find a way to do that easily. Also the fact that the application is common to everyone and the Word document is specific to everyone makes it too complex to maintain consistency across everyone

yeln4ts avatar Aug 01 '22 13:08 yeln4ts

Hi @yeln4ts, I get your point on adding code styling in pwndoc and using the document's styles is a good idea. Unfortunately it is not supported by google docs (it natively supports just normal text and headings from h1 to h6). This lead to code not be styled at all.

Considering the widespread of using google services, is there any chance you can reconsider the option to add some sort of styling directly in the app?

Even something default like Consolas font, white text, black background should be fine. In this way who use word and the defined code style will continue to see the code using the defined style, who do not use word will see something that at least looks like code instead of normal text.

mrnfrancesco avatar Aug 04 '22 17:08 mrnfrancesco

There already is a style in the application for code blocks and code. image

yeln4ts avatar Aug 09 '22 18:08 yeln4ts

Yeah, sure. Unfortunately those two apply a style in the docx based on a style. In case you use Google docs such style doesn't exists and the code is just formatted as normal text.

mrnfrancesco avatar Aug 09 '22 19:08 mrnfrancesco

I don't think there is any solution to your issue then if Google docs does not apply styles.

yeln4ts avatar Aug 09 '22 20:08 yeln4ts

@mrnfrancesco Use table or paragraph with border instead of the codeblock style can be a solution. What do you thing about that ?

nitek29 avatar Sep 02 '22 07:09 nitek29

Using a table/paragraph with borders make easier to isolate the code to the other text, but it still need at least a monospace font to render correctly.

For me the correct solution to match everyone needs is to use syntax highlight or any other code formatting directly as HTML in the app without using a document style. Basically the same that happens when you copy/paste code from VSCode into Word.

mrnfrancesco avatar Sep 02 '22 08:09 mrnfrancesco

FYI #355

nitek29 avatar Dec 01 '22 14:12 nitek29