LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > LinuxQuestions.org > LQ Suggestions & Feedback
User Name
Password
LQ Suggestions & Feedback Do you have a suggestion for this site or an idea that will make the site better? This forum is for you.
PLEASE READ THIS FORUM - Information and status updates will also be posted here.

Notices


Reply
  Search this Thread
Old 10-13-2018, 05:49 AM   #1
Michael Uplawski
Senior Member
 
Registered: Dec 2015
Posts: 1,622
Blog Entries: 40

Rep: Reputation: Disabled
Transform HTML to LQ mark up or -down for posting


Once, I wanted to publish the whole man-page to a tool I had scripted, on my blog, but the formatting was so cumbersome, that I preferred to just link to the HTML-version of the man-page...

Now, it is not clear to me, why transformations of all sorts attract my interest, but be it useful or not, I wrote a XSL-style-sheet to create LQ markup or -down from HTML, published a new blog-post about it and present you the style-sheet in its very first version. The XSL-file is not yet commented, as I deem it superfluous in this case (but I may be erring).

The code-tag on LQ destroys part of the xsl-code, therefore I attach a functional version of the style-sheet as text to my most recent post in this thread.

Cheerio.

Last edited by Michael Uplawski; 10-15-2018 at 11:43 PM. Reason: Left or right, style sheet updated, old version removed
 
Old 10-14-2018, 07:43 AM   #2
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
cool, thanks!
i wrapped it into this shell script:
Code:
#!/bin/sh

! [ -r "$1" ] && echo "Input file \"$1\" is not readable" && exit 1

LQ_BBCODE="${LQ_BBCODE-"$HOME/.local/share/lq_bbcode.xsl"}"

out="${1%.*}.bbcode"
out="${out##*/}"

xsltproc --html -o "$out" "$LQ_BBCODE" "$1"
and it makes this out of your last post:
Quote:
Once, I wanted to publish the whole man-page to a tool I had scripted, on my blog, but the formatting was so cumbersome, that I preferred to just link to the HTML-version of the man-page... Now, it is not clear to me, why transformations of all sorts attract my interest, but be it useful or not, I wrote a XSL-style-sheet to create LQ markdown from HTML , published a new blog-post about it and present you the style-sheet in its very first version. The XSL-file is not yet commented, as I deem it superfluous in this case (but I may be erring). The code-tag on LQ destroys part of the xsl-code, therefore I attach a functional version of the style-sheet as text to this post. Cheerio.
as you can see it ignores the <br> tags (newlines).
could you fix that?

Last edited by ondoho; 10-14-2018 at 07:46 AM.
 
Old 10-14-2018, 08:12 AM   #3
average_user
Member
 
Registered: Dec 2010
Location: Warsaw, Poland
Distribution: Slackware
Posts: 560

Rep: Reputation: 220Reputation: 220Reputation: 220
Markdown? What does it have to do with BBCode that LQ uses?

I think that `<ul>` also doesn't work correctly, for example:
Code:
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title></title>
</head>
<body>

<ul>
<li>1st point
</li>
<li>2nd point
</li>
</ul>
</body>
</html>
ends up as
Code:
   1st point    2nd point
Good job anyway!
 
Old 10-14-2018, 08:21 AM   #4
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by average_user View Post
Markdown? What does it have to do with BBCode that LQ uses?
i think he meant markup. i'm sure bbcode belongs to the large family of markup "languages", just like html, xml etc.
 
Old 10-14-2018, 08:31 AM   #5
average_user
Member
 
Registered: Dec 2010
Location: Warsaw, Poland
Distribution: Slackware
Posts: 560

Rep: Reputation: 220Reputation: 220Reputation: 220
Quote:
Originally Posted by ondoho View Post
i think he meant markup. i'm sure bbcode belongs to the large family of markup "languages", just like html, xml etc.
Yes, probably, that would make sense. I think 'markdown' is a play on 'markup'.
 
Old 10-14-2018, 01:21 PM   #6
Michael Uplawski
Senior Member
 
Registered: Dec 2015
Posts: 1,622

Original Poster
Blog Entries: 40

Rep: Reputation: Disabled
1) I do not know the difference between markdown and markup. As there are less tags in the LQ “formatting language” I have modified my initial post by replacing “markup” by “markdown”. Next time, I just give evidence of my not caring anyway.

2) The XSL-stylesheet does not honor list-tags for the simple reason that I have not yet had any use for them. I will add templates for list tags (ol, ul) and the list-items (li).

3) Right. There is no support for <br/>, yet. I am avoiding this tag in my own code and had no use for it. But I will ad a template for <br/>, too.

Thanks for the feedback, I'll publish a new version of the style-sheet, soon.

Also, there are apparent “bugs”, which do not render the exercise futile, but could easily be corrected to avoid ill-formatted running text or bad line-breaks. All that shall be addressed.

Remember, this was the very first version and only the second style-sheet after many years of abstinence from XSLT. I am still happy with the results

Last edited by Michael Uplawski; 10-14-2018 at 01:29 PM. Reason: bugs.
 
Old 10-15-2018, 12:38 PM   #7
Michael Uplawski
Senior Member
 
Registered: Dec 2015
Posts: 1,622

Original Poster
Blog Entries: 40

Rep: Reputation: Disabled
Hard line-breaks and lists are now honored. The new style-sheet is attached (remove the .txt extension).
Attached Files
File Type: txt html2lq.xsl.txt (4.9 KB, 12 views)
 
Old 10-16-2018, 01:42 AM   #8
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
yes!

testing - on this random post:
Quote:
How to list firmware?
/Background
I tried the 'heads-0.4<blah>' distro, which is remarkably like tails, except is uses no closed source stuff at all at all. First casualty was my wifi firmware (in fact, basically ALL firmware). This is my wifi: Code:
Code:
02:00.0 Network controller: Qualcomm Atheros AR9485 Wireless Network Adapter (rev 01)
/End Background

How can I find the firmware this loads? There's a few firmware versions and revisions for this wifi card
  • lspci -vv doesn't mention it
  • lsusb doesn't find it, unsurprisingly.
  • It only puts a single line in the logs. Nothing about firmware which it definitely uses.
  • I got lost in the kernel source. I confess to not regularly reading kernel sources.

I think loading firmware is a kernel option tails may not have set


I intend to loop mount the cd, copy the files, make some needed adjustments, and repackage that as an iso, and burn my compromised heads iso just to try it. Running without wifi is an 'appalling vista'. I eitherneedf to relocate, decrepit as I am, or grab 20 metres of cat5, run it out the window and in my front door :-//.

I am not worried about security, because if some dweeb manages to detect what cpu atheros uses, and bothers to write a hack to breach the linux security of a card found in 0.002% of PCs worldwide, and manages to upload the nothing I have on my box, he deserves to get in for wasting his life, doesn't he? He probably doesn't understand english anyhow.
perfect in comparison!
nice, thanks!
 
  


Reply

Tags
html, lq, markup, transform, xsl



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Programming a graphical universal markup non-bloated browser (HTML?) Xeratul General 19 05-28-2017 06:16 PM
LXer: Markup lowdown: 4 markup languages every team should know LXer Syndicated Linux News 0 08-26-2015 10:41 AM
How to transform html special characters into readable text Karl Godt Programming 5 03-18-2012 11:52 PM
[SOLVED] No rule to make target 'Markup.cpp', needed by `Markup.o'. Stop. shamjs Programming 11 12-10-2011 10:51 AM
How can I transform XML into HTML on bash? pedrosan Linux - Newbie 0 04-22-2004 02:37 AM

LinuxQuestions.org > Forums > LinuxQuestions.org > LQ Suggestions & Feedback

All times are GMT -5. The time now is 03:41 PM.

Main Menu
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