Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Test post for <code> and <pre>

by siberia-man (Monk)
on Sep 16, 2019 at 17:39 UTC ( #11106250=monkdiscuss: print w/replies, xml ) Need Help??

This is new thread as a branch from the 11104437. Initially I've been said:
Please use <code> or <pre> tags for code samples, otherwise PM interprets [...] as links.
My post has had a code rounded by <pre> only. Later I modified it to apply rounding with <pre><code> to avoid the mentioned isue.

I confirm that anything like [...] is converted to links. <pre><code> resolve this issue. However (for me personally) the <code> generates a monospace text in the tiny font size.

This one is rounded with <pre> only:
something having "word"
within square brackets word
This one is rounded with <code> only:
something having "word" within square brackets [word]
This one is rounded with <pre><code>:
something having "word" within square brackets [word]
This one is rounded with <code><pre>:
<pre> something having "word" within square brackets [word] </pre>

Replies are listed 'Best First'.
Re: Test post for <code> and <pre>
by haukex (Chancellor) on Sep 16, 2019 at 18:09 UTC
    the <code> generates a monospace text in the tiny font size.

    You might want to enable the option "Large Code Font" in your Display Settings.

    Generally, <code> or <c> tags should be used for all code, sample input, output, etc. They do not interpret any other tags or PerlMonks [...] links inside them, and they provide the [download] link. (Update: Note that <code> tags are a special feature of PerlMonks and are not the HTML5 <code> tags.)

    <pre> tags are just HTML formatting tags; they no not prevent the interpretation of other HTML tags or PM [...] links inside them, and AFAIK get no special processing from PM. The only advantage they have is that they support Unicode, while <code> tags unfortunately do not; but you still have to escape all the <>&[] characters inside <pre> tags. (Combining <code> and <pre> doesn't make sense.)

Re: Test post for <code> and <pre>
by Discipulus (Abbot) on Sep 16, 2019 at 18:20 UTC
    Hello siberia-man,

    if you want you can test in scratchpad public or private one ;)

    > generates a monospace text in the tiny font size.

    In Display Settings you have Large Code Font checkbox. I use it..

    ..and I never use <pre> tags but only <code> or <c> short form. See Writeup Formatting Tips where <pre> is not even mentioned.

    For your convenience and small piece of code you can find LanX's wikisyntax useful.



    L*

    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
Re: Test post for <code> and <pre>
by kcott (Bishop) on Sep 17, 2019 at 05:40 UTC

    G'day siberia-man,

    There's a lot of good advice already. Here's some additional information, which I didn't see posted, and mostly reflects my usage (garnered over the last decade).

    The <pre> tag is useful when the content contains non-ASCII characters which may be rendered as character references when <code> tags are used. For in-line, as opposed to block, content I use the <tt> tag. Everything already said about <pre> (e.g. escaping characters) also applies to <tt>. Compare these smilies: &#9786; and (the 1st uses <c>; the 2nd uses <tt>).
    [Note: Rendering of non-ASCII characters may be dependent on various things such as browser capabilities and available fonts.]

    Be aware that <code> tags wrap lines (the 2nd and subsequent parts are introduced with a +); however, <pre> tags won't do this. Keep an eye on the length of lines in <pre> blocks; and bear in mind that indentation from "Re:", "Re^2:", ..., "Re^N:" posts will affect wrapping.

    You can nest <c> inside <code> and vice versa. The two pieces of markup I used there were: <code><c></code> and <c><code></c>.

    You can enter [ and ] using &#91; and &#93;, respectively; e.g. [not a link] which I marked up as just "&#91;not a link&#93;" (i.e. no tags needed here).

    — Ken

Re: Test post for <code> and <pre>
by hippo (Chancellor) on Sep 17, 2019 at 08:28 UTC
Re: Test post for <code> and <pre>
by choroba (Archbishop) on Sep 17, 2019 at 15:55 UTC
    Here you can see how your post renders for me (yes, syntax highlighting is on).

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
Re: Test post for <code> and <pre>
by siberia-man (Monk) on Sep 16, 2019 at 19:09 UTC
    Thanks for answer to all. I've seen the Display Settings when looking for the option responsible for the width of the code block. And I planned to apply it once. But I missed the option supporting the Large font size.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: monkdiscuss [id://11106250]
Approved by haukex
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (6)
As of 2020-04-07 05:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The most amusing oxymoron is:
















    Results (42 votes). Check out past polls.

    Notices?