From Fedora Project Wiki

(bit of re-org cruft)
(removing cruft, adding note about updating this section)
 
(6 intermediate revisions by 3 users not shown)
Line 1: Line 1:
= Wiki2XML =
 
 
 
 
 
== Useful References ==
 
== Useful References ==
  
 
http://fedoraproject.org/wiki/DocsProject/WorkFlow#WikitoDocBookXML
 
http://fedoraproject.org/wiki/DocsProject/WorkFlow#WikitoDocBookXML
  
== Converting from Wiki to XML in MoinMoin ==
+
== Converting from MediaWiki to XML ==
  
{{Anchor|Before_Conversion}}
 
 
=== Before Conversion ===
 
=== Before Conversion ===
  
Line 24: Line 19:
  
 
=== Converting to XML ===
 
=== Converting to XML ===
1. Page must first follow guidelines in [#Before_Conversion]
 
1. Go to the page you want to convert
 
1. In the right-side navigation choose ''More Actions: > Render as Docbook''
 
1. Note the format of the URL; this format can be used with wget, e.g.:
 
wget http://fedoraproject.org/wiki/Docs/Drafts/DesktopUserGuide/Introduction?action=format&mimetype=xml/docbook
 
* That is the basis of a script for getting all the pages
 
1. Save the rendered page in the proper place as a file with the same name as the wiki page: <code>/path/to/guide-name/devel/en_US/Introduction.xml</code>
 
1. The XML files need a standard book structure, including a Makefile, a source-language directory such as en_US where the XML files live, and the special file <code>en_US/rpm-info.xml</code>.  The entities file <code>en_US/doc-entities.xml</code> is optional; if you don't know what it does, you don't need it.
 
* These all live in <code>module-name/devel/</code>
 
1. Once an XML file, the file itself needs numerous changes to make it do the following:
 
* Match actual DocBook XML 4.4 requirements
 
* Build using Fedora Docs toolchain
 
* Fit into an <article> or <book> structure
 
1. Loop through the document file by file or with any kind of script covered in [[DocsProject/Tools/Wiki2XML| DocsProject/Tools/Wiki2XML]] .  Follow the clean-up techniques described below in [#Clean-up_DocBook_XML:Clean-up DocBook XML] .
 
  
{{Anchor|Clean-up_DocBook_XML}}
+
# Install <code>python-mwlib</code> package.
=== Clean-up DocBook XML ===
+
# Run this command to render one page: <code>/usr/bin/mw-render -c http://fedoraproject.org/w/ -w docbook PageTitle -o output.xml</code>
 +
# Make a script or for-loop to iterate through a list of pages.
  
To make sure your XML is formatted according to DocsProject standards, use:
+
If you have more than a few files, you may want to use this process to make it easier:
  
 +
* Make a plain text file <code>/tmp/wiki_pages</code> with the name of each wiki article on a line by itself.  The name should include the underscore '_' instead of spaces, but no brackets or file extensions:
 +
<pre>
 +
Chapter_One_-_Called_something
 +
Chapter_Two_-_Called_another_thing
 +
...
 +
</pre>
 +
* Use this for-loop to iterate through each file, rendering it to XML:
 
<pre>
 
<pre>
for i in *.xml; do xmlformat -f <location of docs-common-folder>/bin/xmlformat-fdp.conf $i > tmpfile && mv tmpfile $i; done
+
mkdir XML_files
 +
for i in `cat /tmp/wiki_files`;
 +
    do /usr/bin/mw-render -c http://fedoraproject.org/w/ -w docbook $i -o XML_files/$i.xml;
 +
done
 
</pre>
 
</pre>
  
{{Anchor|Processing_DocBook_Pages}}
 
 
=== Processing DocBook Pages ===
 
=== Processing DocBook Pages ===
 +
 +
{{admon/note|This content needs updating for <code>mw-render</code>.|This content needs reviewing and updating based on the current output from <code>mw-render</code> and what is required to clean it up for <code>publican</code>.}}
  
 
Follow this process guideline with each XML file:
 
Follow this process guideline with each XML file:
  
1. Open the file in a full-featured text editor
+
# Open the file in a full-featured text editor
1. Ensure the XML file has the proper header, with proper chapters or sections
+
# Ensure the XML file has the proper header, with proper chapters or sections
1. Search through the file for each of the markup output types covered in [#Wiki_markup_output_to_XML,_mapped_to_DocBook_XML Wiki markup output to XML, mapped to DocBook XML] ; that is, do the following:
+
## Change to 'chapter' type
1. Search for each instance of <emphasis> and replace it with the proper DocBook contextual markup
+
# Remove extraneous XML stylesheet call
1. Search for each instance of <emphasis role='strong'> and replace it with the proper DocBook contextual markup
+
# Change XML file type within the file
1. Search for each instance of <code> and replace it with the proper DocBook contextual markup
+
## book => 0
 +
## article => chapter
 +
## articleinfo => 0
 +
# Search through the file for each of the markup output types covered in [#Wiki_markup_output_to_XML,_mapped_to_DocBook_XML Wiki markup output to XML, mapped to DocBook XML] ; that is, do the following:
 +
# Search for each instance of 'emphasis' and replace it with the proper DocBook contextual markup
 +
# Search for each instance of 'code' and 'programlisting' and replace it with the proper DocBook contextual markup
 +
# Search and replace empty literallayout containers
 +
# Convert inlinemediaobject to proper admonition
  
{{Anchor|Wiki_markup_output_to_XML,_mapped_to_DocBook_XML}}
 
 
=== Wiki markup output to XML, mapped to DocBook XML ===
 
=== Wiki markup output to XML, mapped to DocBook XML ===
 
+
<!-- This content is accurate -->
 
<pre>
 
<pre>
 
Was ''two-ticks'' (<code>''two-ticks''</code>) in wiki
 
Was ''two-ticks'' (<code>''two-ticks''</code>) in wiki
Line 135: Line 134:
  
 
It's best not to hyperlink other text because in some formats people may have a hard time finding the actual URL.  Edit judiciously.
 
It's best not to hyperlink other text because in some formats people may have a hard time finding the actual URL.  Edit judiciously.
 +
 +
[[Category:Docs_Project_process]]

Latest revision as of 00:46, 18 March 2010

Useful References

http://fedoraproject.org/wiki/DocsProject/WorkFlow#WikitoDocBookXML

Converting from MediaWiki to XML

Before Conversion

The document needs to follow these lengthy but accurate guidelines:

Converting to XML

  1. Install python-mwlib package.
  2. Run this command to render one page: /usr/bin/mw-render -c http://fedoraproject.org/w/ -w docbook PageTitle -o output.xml
  3. Make a script or for-loop to iterate through a list of pages.

If you have more than a few files, you may want to use this process to make it easier:

  • Make a plain text file /tmp/wiki_pages with the name of each wiki article on a line by itself. The name should include the underscore '_' instead of spaces, but no brackets or file extensions:
Chapter_One_-_Called_something
Chapter_Two_-_Called_another_thing
...
  • Use this for-loop to iterate through each file, rendering it to XML:
mkdir XML_files
for i in `cat /tmp/wiki_files`;
    do /usr/bin/mw-render -c http://fedoraproject.org/w/ -w docbook $i -o XML_files/$i.xml;
done

Processing DocBook Pages

Note.png
This content needs updating for mw-render.
This content needs reviewing and updating based on the current output from mw-render and what is required to clean it up for publican.

Follow this process guideline with each XML file:

  1. Open the file in a full-featured text editor
  2. Ensure the XML file has the proper header, with proper chapters or sections
    1. Change to 'chapter' type
  3. Remove extraneous XML stylesheet call
  4. Change XML file type within the file
    1. book => 0
    2. article => chapter
    3. articleinfo => 0
  5. Search through the file for each of the markup output types covered in [#Wiki_markup_output_to_XML,_mapped_to_DocBook_XML Wiki markup output to XML, mapped to DocBook XML] ; that is, do the following:
  6. Search for each instance of 'emphasis' and replace it with the proper DocBook contextual markup
  7. Search for each instance of 'code' and 'programlisting' and replace it with the proper DocBook contextual markup
  8. Search and replace empty literallayout containers
  9. Convert inlinemediaobject to proper admonition

Wiki markup output to XML, mapped to DocBook XML

Was ''two-ticks'' (<code>''two-ticks''</code>) in wiki
     \=> <emphasis> => <application>, <guibutton>, <keycap>, <keycode>, <keycombo>,
                       <firstterm>, <menuchoice>, <guimenu>, <guisubmenu>, 
                       <guimenuitem>, <guilabel>, <guibutton>, <guiicon>, <glossterm>

Was '''three-ticks''' (<code>'''three-ticks'''</code>) in Wiki
     \=> <emphasis> => <application>

Was <code></code> in wiki
     \=> <programlisting> => <command>, <filename>, <classname>
         <programlisting format="linespecific"> => <command>, <filename>, <classname>

Was <pre /> block in wiki
     \=> <programlisting> block

Was <something_replaceable> in wiki
     \=> <something_replaceable> => <replaceable>something</replaceable>

guibutton, key*

Remove the "[] " and "+", these are handled by the XSL/CSS.

Example Usage

The following examples show very short <para> (paragraph) elements as examples.

menuchoice/gui*

To indicate a selection from a graphical menu in DocBook XML, retag like this:

<para>From the main menu, select <menuchoice>
<guimenu>System</guimenu>
<guisubmenu>Administration</guisubmenu>
<guimenuitem>Display</guimenuitem>
</menuchoice>.</para>

You do not need to put the > symbol in, that is handled by the XSL or CSS.

key*

To indicate a key combination in DocBook XML, retag like this:

<para>To reboot, hit <keycombo>
<keycap>Ctrl</keycap>
<keycap>Alt</keycap>
<keycap>Delete</keycap>
</keycombo>.</para>

screen

To show multiline commands, break out a single important command line, or show a section of a configuration file or output in DocBook XML, retag like this:

<para>Run the following commands:</para>
<screen><![CDATA[rpm -qa 'kernel' > /tmp/kernels1.txt
]rpm -qa 'kernel*' > /tmp/kernels2.txt
diff -u /tmp/kernels?.txt  ></screen>

Notice that the <![CDATA[ ... ] > content allows you type anything verbatim between the markers. This means you don't have to change special characters like < > & into their XML character entity equivalents. This simplifies the process somewhat, but you can't use any XML tags between the <![CDATA[ ... ] > markers, of course. Avoid putting in extra space such as line breaks.

ulink (URLs)

To make a link to a URL:

Visit my page at <ulink url="http://example.com/mypage.html" />.

It's best not to hyperlink other text because in some formats people may have a hard time finding the actual URL. Edit judiciously.