0

Sometimes when I'm editing posts which need preformatting (mainly code pre formats), If I click on the {} icon on editing tools tab:

enter image description here

I can't achieve the effect I want, instead the text appears to be just indented and not preformatted as a block. I have noticed this frequently with lengthy paragraphs which need to be formatted as code. Inline preformatting works fine with `` .

How can I create a preformatted block of text during editing? For example I was trying to edit this post: Tasker to programmatically uninstall apps.

0

2 Answers 2

2

The post that you wanted to edit looked like this:


This is what I got so far, it might not be the most efficient way to do it.

  • I run the following command via Termux Task plugin.

pm list packages >/storage/emulated/0/Apps.txt diff --unchanged-line-format= --old-line-format= --new-line-format='%L' /storage/emulated/0/BaselineApps.txt /storage/emulated/0/Apps.txt | sed 's/^[^:]*://' >/storage/emulated/0/NewApps.txt

  • Read file NewApps.txt to variable %Apps

I suggest, instead of using whitespaces in every line, use <pre> and </pre> at the beginning of first line and end of last line.

E.g.

<pre>

LINE1
LINE2

<pre>

If you're editing the text which falls between a list, simply add one whitespace before <pre> to align the whole preformatted text with the list. E.g.


This is what I got so far, it might not be the most efficient way to do it.

  • I run the following command via Termux Task plugin.
    pm list packages >/storage/emulated/0/Apps.txt
    diff --unchanged-line-format= --old-line-format= --new-line-format='%L' /storage/emulated/0/BaselineApps.txt /storage/emulated/0/Apps.txt | sed 's/^[^:]*://' >/storage/emulated/0/NewApps.txt
    
  • Read file NewApps.txt to variable %Apps
3
  • Now that is a perfect answer! thanks Commented Dec 13, 2017 at 18:50
  • Instead of the <pre> you can also use 3 back-ticks on separate lines (i.e. 3 before and 3 after). Usually you can follow the introductionary 3 by the format, e.g. html, to have syntax highlighting – but that doesn't work on all SE sites.
    – Izzy Mod
    Commented Dec 13, 2017 at 22:50
  • @Izzy thanks for the input Commented Dec 20, 2017 at 18:51
2

Oh my, I just found the solution:

enter image description here

So the solution is indenting the target text by eight spaces

It seems my issue was that I was trying to create preformatted block within a list.

For related markdown this article also helps, Markdown help. They also state another way of doing this; Highlighting target text and pressing ctrl+K

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .