LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Blogs > Michael Uplawski
User Name
Password

Notices


Rate this Entry

Transform HTML to LQ markup or -down

Posted 10-13-2018 at 05:37 AM by Michael Uplawski
Updated 11-10-2018 at 12:32 AM by Michael Uplawski

Again, I have written a XSL stylesheet.

This time, it serves me to facilitate writing posts and blog entries, here on LinuxQuestions.org, by transforming HTML to the markdown-syntax supported by LQ.

Taken the html-version of a man-page, like for HTML2Index, which is generated automatically alongside the other file-formats (PDF and man), I can call an xsltprocessor, like xsltproc with the new stylesheet and get a text-version of the HTML-page, ready to be copied&pasted to, either my blog (as I did) or a forum post.

For HTML2index, the command had been:
Code:
xsltproc --html -o ./html2index.txt ./html2lq.xsl ../html/html2index.html
.

See the result in my updated blog entry.

Here is the style-sheet (Remove the '.txt' extension).
The code-tag on LQ destroys part of the XSL-code, therefore I will not show you the style-sheet right in this blog entry
Ω
Attached Files
File Type: txt html2lq.xsl.txt (4.9 KB, 9 views)
« Prev     Main     Next »
Total Comments 2

Comments

  1. Old Comment
    nice!

    a little shell script wrapper:
    Code:
    #!/bin/sh
    
    default="$HOME/.local/share/lq_bbcode.xsl"
    LQ_BBCODE="${LQ_BBCODE-"$default"}"
    
    usage() {
    echo "
    Usage:
    
    $0 infile
    
    Output to stdout
    
    The shell variable LQ_BBCODE points to the XSL file to be used
    currently: $LQ_BBCODE
    default: $default
    "
    	exit 1
    }
    
    ! [ -r "$1" ] && echo "Input file \"$1\" is not readable" && usage
    
    xsltproc --html "$LQ_BBCODE" "$1" 2>/dev/null
    Posted 10-16-2018 at 01:58 AM by ondoho ondoho is offline
  2. Old Comment
    TY for the script.
    Posted 10-17-2018 at 02:20 PM by Michael Uplawski Michael Uplawski is offline
 

  



All times are GMT -5. The time now is 10:55 AM.

Main Menu
Advertisement
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration