LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   LQ Suggestions & Feedback (https://www.linuxquestions.org/questions/lq-suggestions-and-feedback-7/)
-   -   Transform HTML to LQ mark up or -down for posting (https://www.linuxquestions.org/questions/lq-suggestions-and-feedback-7/transform-html-to-lq-mark-up-or-down-for-posting-4175640287/)

Michael Uplawski 10-13-2018 05:49 AM

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.

ondoho 10-14-2018 07:43 AM

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?

average_user 10-14-2018 08:12 AM

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!

ondoho 10-14-2018 08:21 AM

Quote:

Originally Posted by average_user (Post 5914613)
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.

average_user 10-14-2018 08:31 AM

Quote:

Originally Posted by ondoho (Post 5914619)
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'.

Michael Uplawski 10-14-2018 01:21 PM

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. :p

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 :cool:

Michael Uplawski 10-15-2018 12:38 PM

1 Attachment(s)
Hard line-breaks and lists are now honored. The new style-sheet is attached (remove the .txt extension).

ondoho 10-16-2018 01:42 AM

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!


All times are GMT -5. The time now is 04:56 AM.