Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

perl.j:

Ah, so you're doing it as a learning exercise, then? In that case, the first thing I'd do is figure out what the grammar for my markup would be, and what it would mean. Sketch it out on a sheet of paper. Then, start writing code to read the text and parse out your instructions. If it gets nasty, you might change your grammar to simplify it.

The roff, troff, etc., layout programs kept their grammar simple by using the rule "if a line begins with a period, then it's a layout command, otherwise it's text". So a marked-up file would look like this:

.TH 7z 1 "September 1 2006" "Mohammed Adnene Trojette" + .SH NAME 7z \- A file archiver with highest compression ratio .SH SYNOPSIS .B 7z .BR [adeltux] .BR [\-] .BR [SWITCH] .BR <ARCHIVE_NAME> .BR <ARGUMENTS>... .PP .SH DESCRIPTION 7-Zip is a file archiver with the highest compression ratio. The progr +am supports 7z (that implements LZMA compression algorithm), ZIP, CAB +, ARJ, GZIP, BZIP2, TAR, CPIO, RPM and DEB formats. Compression ratio + in the new 7z format is 30-50% better than ratio in ZIP format. .TP 7z uses plugins to handle archives. .PP

This is the first few lines of the man page for 7z. The man system in *NIX uses *roff formatted files. On most(?) Linux systems, you can read man 7 groff to get details on the grammar used.

...roboticus

When your only tool is a hammer, all problems look like your thumb.


In reply to Re^3: Make a Markup Method in Perl? by roboticus
in thread Make a Markup Method in Perl? by perl.j

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-04-26 03:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found