expanding =begin

[email protected] (Ricardo Signes)
Newsgroups perl.pod-people
Message-ID <[email protected]>
From perlpodspec:

   "=begin formatname"
       This marks the following paragraphs (until the matching "=end
       formatname") as being for some special kind of processing.  Unless
       "formatname" begins with a colon, the contained non‐command
       paragraphs are data paragraphs.  But if "formatname" does begin
       with a colon, then non‐command paragraphs are ordinary paragraphs
       or data paragraphs.  This is discussed in detail in the section
       "About Data Paragraphs and "=begin/=end" Regions".

       It is advised that formatnames match the regexp
       "m/\A:?[−a−zA−Z0−9_]+\z/".  Implementors should anticipate future
       expansion in the semantics and syntax of the first parameter to
       "=begin"/"=end"/"=for".

I'd like to extend this definition a bit.  I would replace the second paragraph
with:

   "=begin formatname"
   "=begin formatname parameter"
       This marks the following paragraphs (until the matching "=end
       formatname") as being for some special kind of processing.  Unless
       "formatname" begins with a colon, the contained non‐command
       paragraphs are data paragraphs.  But if "formatname" does begin
       with a colon, then non‐command paragraphs are ordinary paragraphs
       or data paragraphs.  This is discussed in detail in the section
       "About Data Paragraphs and "=begin/=end" Regions".

       It is advised that formatnames match the regexp
       "m/\A:?[−a−zA−Z0−9_]+\z/".  Everything following whitespace after the
       formatname is a parameter that may be used by the formatter when dealing
       with this region.  Implementors should anticipate future
       expansion in the semantics and syntax of the first parameter to
       "=begin"/"=end"/"=for".

This allows for constructions like:

  =begin syntax javascript

  =end syntax

...or...

  =begin table width(10) height(9)

  =end table

...or...

  =begin dialect Pod6

  =end dialect

I believe several parsers already allow this implicitly.

-- 
rjbs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.