Formatting code/scripts/configuration files rendered on a website

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Hendrik Maryns

    Formatting code/scripts/configuration files rendered on a website

    Hi,

    Since I was so pleased to discover how to enable my keyboard to type
    symbols like … directly, I made a howto-page about it:
    http://tcl.sfs.uni-tuebingen.de/~hendrik/keyboard.shtml.

    I tried to follow the advice from
    http://xhtml.com/en/xhtml/reference/pre/ to not use the <pretag, but I
    am not satisfied with it, since tabs are not preserved (see bottom
    part). This is not essential here, but would be nice. Can I do that
    with an addition to the CSS given on the link above? (I removed #
    margin: 1px 0; since I don’t like it.)

    H.
    --
    Hendrik Maryns

    =============== ===

    Ask smart questions, get good answers:

  • Hendrik Maryns

    #2
    Re: Formatting code/scripts/configuration files rendered on a website

    Hendrik Maryns schreef:
    Hi,
    >
    Since I was so pleased to discover how to enable my keyboard to type
    symbols like … directly, I made a howto-page about it:
    http://tcl.sfs.uni-tuebingen.de/~hendrik/keyboard.shtml.
    >
    I tried to follow the advice from
    http://xhtml.com/en/xhtml/reference/pre/ to not use the <pretag, but I
    am not satisfied with it, since tabs are not preserved (see bottom
    part). This is not essential here, but would be nice. Can I do that
    with an addition to the CSS given on the link above? (I removed #
    margin: 1px 0; since I don’t like it.)
    Ok, found it already, simply add

    white-space: pre;

    to ol.code-unnumbered li (note: *not* to ol.code-unnumbered).

    H.
    --
    Hendrik Maryns

    =============== ===

    Ask smart questions, get good answers:

    Comment

    • Jukka K. Korpela

      #3
      Re: Formatting code/scripts/configuration files rendered on a website

      Scripsit Hendrik Maryns:
      I tried to follow the advice from
      http://xhtml.com/en/xhtml/reference/pre/ to not use the <pretag,
      Why? Their page looks reasonable (at least when viewed text-only, the
      usual bogosity check), and they have a superficially good argument
      (<precarries no meaning), but what _is_ this xhtml.com? The only
      information I found easily is an obfuscated E-mail address:
      "For comments about xhtml.com, please contact: feedback [at] xhtml.com"

      This gives an initial expectation of credibility around -100.

      The argument isn't really that good. What do you use instead? If you
      have data where whitespace really matters, like Python code, then why
      would you _rely_ on CSS as regards to getting this important _content_
      information delivered?

      The usual CSS Caveats imply that <pre>, rather than any CSS constructs,
      are the right way to go if the data _is_ really preformatted plain text
      and preserving that is essential.
      but I am not satisfied with it, since tabs are not preserved
      By HTML specifications, tab stops should appear in a certain way _and_
      authors should not rely on this. Use the safe way: spaces.

      --
      Jukka K. Korpela ("Yucca")


      Comment

      • Harlan Messinger

        #4
        Re: Formatting code/scripts/configuration files rendered on a website

        Jukka K. Korpela wrote:
        Scripsit Hendrik Maryns:
        >
        >I tried to follow the advice from
        >http://xhtml.com/en/xhtml/reference/pre/ to not use the <pretag,
        >
        Why? Their page looks reasonable (at least when viewed text-only, the
        usual bogosity check), and they have a superficially good argument
        (<precarries no meaning), but what _is_ this xhtml.com? The only
        information I found easily is an obfuscated E-mail address:
        "For comments about xhtml.com, please contact: feedback [at] xhtml.com"
        >
        This gives an initial expectation of credibility around -100.
        There are no limits to the irrelevance of the factors on which you base
        your credibility assessments, are there? Their credibility on the value
        of the PRE tag can be judged by your personal feelings about munged
        e-mail addresses? That's like saying that the initial expectation of
        credibility of the remainder of your response (which is a great
        treatment) is -100% because of your bogus invocation of their approach
        to contact information.

        Comment

        • Jukka K. Korpela

          #5
          Re: Formatting code/scripts/configuration files rendered on a website

          Scripsit Harlan Messinger:
          Their credibility on
          the value of the PRE tag can be judged by your personal feelings
          about munged e-mail addresses?
          No, their _general_ credibility gets a low initial score due to the
          _fact_ that they don't even tell who they are (and don't even tell their
          names and real e-mail address).
          That's like saying that the initial
          expectation of credibility of the remainder of your response (which
          is a great treatment) is -100% because of your bogus invocation of
          their approach to contact information.
          That's like your usual babbling about irrelevant things. I think you
          could do better. You might have, for example, made a _single_ reasonable
          or reasonable-looking comment on the on-topic issue whether <preshould
          really be avoided in favor of CSS (or even on the remotely-on-topic
          issue whether xhtml.com should be relied on).

          --
          Jukka K. Korpela ("Yucca")


          Comment

          • Harlan Messinger

            #6
            Re: Formatting code/scripts/configuration files rendered on a website

            Jukka K. Korpela wrote:
            Scripsit Harlan Messinger:
            >
            >Their credibility on
            >the value of the PRE tag can be judged by your personal feelings
            >about munged e-mail addresses?
            >
            No, their _general_ credibility gets a low initial score due to the
            _fact_ that they don't even tell who they are (and don't even tell their
            names and real e-mail address).
            ?? Most products you buy in the store carry neither the name of the
            owner or CEO of either the manufacturer or the store. Why does a website
            have to carry the name of its owner?
            >
            >That's like saying that the initial
            >expectation of credibility of the remainder of your response (which
            >is a great treatment) is -100% because of your bogus invocation of
            >their approach to contact information.
            >
            That's like your usual babbling about irrelevant things.
            Gee, responding when I call you on your appeal to irrelevant factors by
            pretending it's irrelevant. Did you think of that all by yourself?
            I think you
            could do better. You might have, for example, made a _single_ reasonable
            or reasonable-looking comment on the on-topic issue whether <preshould
            really be avoided in favor of CSS (or even on the remotely-on-topic
            issue whether xhtml.com should be relied on).
            Nice job of hand-waving.

            Comment

            • Stanimir Stamenkov

              #7
              Re: Formatting code/scripts/configuration files rendered on a website

              Wed, 18 Jun 2008 14:44:14 +0200, /Hendrik Maryns/:
              I tried to follow the advice from
              http://xhtml.com/en/xhtml/reference/pre/ to not use the <pretag,
              If the only reason not use <preis it "has no semantic meaning" you
              could give it meaning, like:

              <pre><code>.. .</code></pre>

              At least I use the above often and there's a <blockcode[1] element
              in the XHTML 2 draft which I mimic using that markup. Depending on
              the content you could use also:

              <pre><samp>.. .</samp></pre>

              I guess one could come up with more examples. I tend to think of
              <preas paragraph or generic block (<div>), interchangeably , which
              has some predefined styling.

              [1]


              --
              Stanimir

              Comment

              • Andy Dingley

                #8
                Re: Formatting code/scripts/configuration files rendered on a website

                On 18 Jun, 20:19, "Jukka K. Korpela" <jkorp...@cs.tu t.fiwrote:
                No, their _general_ credibility gets a low initial score due to the
                _fact_ that they don't even tell who they are (and don't even tell their
                names and real e-mail address).
                The problem with that logic is that it describes Richard Bullis as
                credible,
                because his self-evident stupidity is such a strong authentication of
                his identity.

                Comment

                • Hendrik Maryns

                  #9
                  Re: Formatting code/scripts/configuration files rendered on a website

                  Jukka K. Korpela schreef:
                  Scripsit Hendrik Maryns:
                  >
                  >I tried to follow the advice from
                  >http://xhtml.com/en/xhtml/reference/pre/ to not use the <pretag,
                  >
                  Why? Their page looks reasonable (at least when viewed text-only, the
                  usual bogosity check), and they have a superficially good argument
                  (<precarries no meaning), but what _is_ this xhtml.com? The only
                  information I found easily is an obfuscated E-mail address:
                  "For comments about xhtml.com, please contact: feedback [at] xhtml.com"
                  >
                  This gives an initial expectation of credibility around -100.
                  Notwithstanding your objections, I found the site very helpful,
                  containing nice suggestions to format <codeand <kbd>.
                  The argument isn't really that good. What do you use instead? If you
                  have data where whitespace really matters, like Python code, then why
                  would you _rely_ on CSS as regards to getting this important _content_
                  information delivered?
                  >
                  The usual CSS Caveats imply that <pre>, rather than any CSS constructs,
                  are the right way to go if the data _is_ really preformatted plain text
                  and preserving that is essential.
                  >
                  >but I am not satisfied with it, since tabs are not preserved
                  >
                  By HTML specifications, tab stops should appear in a certain way _and_
                  authors should not rely on this. Use the safe way: spaces.
                  Can you explain this further? I do not want to use spaces there since
                  that’s not what I use in the original file as well. Tabs are meant for
                  aligning, right, well, that’s just what I want to happen there.

                  I could wrap the whole thing in a table, right, but that would make it
                  more work than it’s worth.

                  Cheers, H.
                  --
                  Hendrik Maryns

                  =============== ===

                  Ask smart questions, get good answers:

                  Comment

                  • Hendrik Maryns

                    #10
                    Re: Formatting code/scripts/configuration files rendered on a website

                    Stanimir Stamenkov schreef:
                    Wed, 18 Jun 2008 14:44:14 +0200, /Hendrik Maryns/:
                    >
                    >I tried to follow the advice from
                    >http://xhtml.com/en/xhtml/reference/pre/ to not use the <pretag,
                    >
                    If the only reason not use <preis it "has no semantic meaning" you
                    could give it meaning, like:
                    >
                    <pre><code>.. .</code></pre>
                    Hm, but what with the example from the site I gave? It is not really
                    code, but rather some configuration information in a file.
                    <pre><samp>.. .</samp></pre>
                    This seems more appropriate, but maybe just <preseems the right way to
                    go, really, as Jukka suggested.

                    H.
                    --
                    Hendrik Maryns

                    =============== ===

                    Ask smart questions, get good answers:

                    Comment

                    • Jukka K. Korpela

                      #11
                      Re: Formatting code/scripts/configuration files rendered on a website

                      Scripsit Stanimir Stamenkov:
                      If the only reason not use <preis it "has no semantic meaning" you
                      could give it meaning, like:
                      >
                      <pre><code>.. .</code></pre>
                      That does not give any meaning to <pre>. Using semantic markup inside
                      non-semantic markup does not make the outer markup any more markup. Au
                      contraire, it empasizes its semantic emptyness.

                      Yet, <preis the only way in HTML to specify that whitespace is
                      significant, so if your data has "a b" that shall be intepreted as
                      different from "a b" in meaning, then <preis the correct markup.

                      --
                      Jukka K. Korpela ("Yucca")


                      Comment

                      • Jukka K. Korpela

                        #12
                        Re: Formatting code/scripts/configuration files rendered on a website

                        Scripsit Hendrik Maryns:
                        >By HTML specifications, tab stops should appear in a certain way
                        >_and_ authors should not rely on this. Use the safe way: spaces.
                        >
                        Can you explain this further?
                        Quoting the HTML 4.01 spec (which echoes HTML 2, though with some
                        obscurity):

                        "The horizontal tab character [...] is usually interpreted by visual
                        user agents as the smallest non-zero number of spaces necessary to line
                        characters up along tab stops that are every 8 characters. We strongly
                        discourage using horizontal tabs in preformatted text since it is common
                        practice, when editing, to set the tab-spacing to other values, leading
                        to misaligned documents."



                        Well, it doesn't explain much. But tab stop settings may depend on the
                        environment, so the tab character does not work reliably.
                        I do not want to use spaces there since
                        that’s not what I use in the original file as well.
                        Yet, it's the effect that matters, and spaces are the safe way to
                        achieve that.

                        I've used the M-x untabify function in Emacs, the text editor, when I
                        have needed to convert text with tabs to text without them.
                        I could wrap the whole thing in a table, right, but that would make it
                        more work than it’s worth.
                        I agree that it's not very practical, and neither is the idea of using
                        <divmarkup with classes and styling - though this would be the way to
                        achieve indentation that is easily modified just by changing one CSS
                        rule.

                        --
                        Jukka K. Korpela ("Yucca")


                        Comment

                        • Stanimir Stamenkov

                          #13
                          Re: Formatting code/scripts/configuration files rendered on a website

                          Thu, 19 Jun 2008 20:00:52 +0300, /Jukka K. Korpela/:
                          Scripsit Stanimir Stamenkov:
                          >
                          >If the only reason not use <preis it "has no semantic meaning" you
                          >could give it meaning, like:
                          >>
                          ><pre><code>... </code></pre>
                          >
                          That does not give any meaning to <pre>. Using semantic markup inside
                          non-semantic markup does not make the outer markup any more markup. Au
                          contraire, it empasizes its semantic emptyness.
                          >
                          Yet, <preis the only way in HTML to specify that whitespace is
                          significant, so if your data has "a b" that shall be intepreted as
                          different from "a b" in meaning, then <preis the correct markup.
                          So combining "the <premeaning is a block where whitespace matters"
                          further marking the content as <codeseems good way to go, or I'm
                          missing something?

                          --
                          Stanimir

                          Comment

                          • Jukka K. Korpela

                            #14
                            Re: Formatting code/scripts/configuration files rendered on a website

                            Scripsit Stanimir Stamenkov:
                            So combining "the <premeaning is a block where whitespace matters"
                            further marking the content as <codeseems good way to go, or I'm
                            missing something?
                            I think that's the best way for computer code where whitespace matters.

                            Using <codeis not pragmatically very important, since <premarkup
                            already sets the font to monospace, but <codecarries semantic
                            information, could be used for styling, and it is observed by some
                            automatic translation software (so that they treat <codecontents as
                            literal, to be preserved as such).

                            For example, if you have both blocks of code and some fragments of code
                            in paragraphs, using <codefor all code is a good idea, for uniform
                            styling. (Or for non-uniform in a controlled manner, via classes, since
                            you might wish to make a visual distinction e.g. between source program
                            code and operating system commands.)

                            --
                            Jukka K. Korpela ("Yucca")


                            Comment

                            • Chris F.A. Johnson

                              #15
                              Re: Formatting code/scripts/configuration files rendered on a website

                              On 2008-06-19, Stanimir Stamenkov wrote:
                              Thu, 19 Jun 2008 20:00:52 +0300, /Jukka K. Korpela/:
                              >Scripsit Stanimir Stamenkov:
                              >>
                              >>If the only reason not use <preis it "has no semantic meaning" you
                              >>could give it meaning, like:
                              >>>
                              >><pre><code>.. .</code></pre>
                              >>
                              >That does not give any meaning to <pre>. Using semantic markup inside
                              >non-semantic markup does not make the outer markup any more markup. Au
                              >contraire, it empasizes its semantic emptyness.
                              >>
                              >Yet, <preis the only way in HTML to specify that whitespace is
                              >significant, so if your data has "a b" that shall be intepreted as
                              >different from "a b" in meaning, then <preis the correct markup.
                              >
                              So combining "the <premeaning is a block where whitespace matters"
                              further marking the content as <codeseems good way to go, or I'm
                              missing something?
                              Rather than two nested elements, I'd use a class:

                              <pre class="code">

                              --
                              Chris F.A. Johnson <http://cfaj.freeshell. org>
                              =============== =============== =============== =============== =======
                              Author:
                              Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)

                              Comment

                              Working...