News for hackers. Stuff that matters.
Re:Markdown.css – Make HTML look like plain-text markdown by kiwidrew on Wednesday December 28, 2016 @06:58PM (#13274731)
While I can't imagine why anyone would want/need to do this... it does do a great job at demonstrating the flexibility of modern CSS! The most clever bit (to me) is the underline characters on the <h1> element.
Re:Markdown.css – Make HTML look like plain-text markdown by throwaway2016a on Wednesday December 28, 2016 @07:12PM (#13274797)
The underline on the <h1> just uses the :after psuedo class with some absolute positioning and some padding. Just like almost every other class here. I'm curious what sticks out to you as extra clever with the <h1> vs the other elements that also use :before / :after
Re:Markdown.css – Make HTML look like plain-text markdown by matchu on Thursday December 29, 2016 @01:25AM (#13275976)
The tricky part is rendering the correct number of equals signs. Markdown.css fakes it by rendering a constant large number of equals signs, then setting the width so that only some are visible.
Re:Markdown.css – Make HTML look like plain-text markdown by timlyo on Thursday December 29, 2016 @05:06AM (#13276555)
It seems to work by printing lots of `=` beneath, and then hiding the overflow. Inspecting and changing the title's width reveals more `=` and makes it possible to display half of one.
Re:Markdown.css – Make HTML look like plain-text markdown by pvdebbe on Thursday December 29, 2016 @06:36AM (#13276794)
For one thing I could publish plain markdown as a nerdy blog page and not worry about them 60-character lines break on mobile. I like the look of well formed plain text but it never works elsewhere other than big screens.
Re:Markdown.css – Make HTML look like plain-text markdown by mrcoles on Thursday December 29, 2016 @02:54PM (#13279592)
Thx! If I recall, I think the blockquotes were the trickiest one in writing this. I used the same repeated element trick and overflow hidden, but getting the line breaks in there was the final missing piece: https://github.com/mrcoles/markdown-css/blob/master/markdown...

Also, your first sentence is asking the wrong question ;P

Re:Markdown.css – Make HTML look like plain-text markdown by ComputerGuru on Wednesday December 28, 2016 @07:16PM (#13274814)
I don't get all the hate for this. I think it's very nifty and actually has a number of easy applications right off the top of my head. You've basically just built an html-to-plaintext conversion utility, using your browser's HTML parser/render instead of writing your own. You've taken a difficult-to-parse syntax and changed it to plaintext, after which it can be marked up (or down) as needed for whatever application you have in mind.

Cool.

(immediate "tags" that my brain went to upon seeing this: printer mode, accessibility modes for visually impaired, text-to-kindle, text-to-audio)

Re:Markdown.css – Make HTML look like plain-text markdown by lisper on Wednesday December 28, 2016 @09:47PM (#13275357)
> You've basically just built an html-to-plaintext conversion utility

That's not what this is. Try copying the markdown so you can edit it as you suggest and you will find it doesn't work. The output looks like markdown, but it isn't markdown, and that's the source of the negative reactions. Having a one-to-one correspondence between representation and rendering is the main thing that makes markdown useful. Making something look like markdown but not actually be markdown strips it of nearly all of its utility.

Re:Markdown.css – Make HTML look like plain-text markdown by coldtea on Thursday December 29, 2016 @03:28AM (#13276291)
>Having a one-to-one correspondence between representation and rendering is the main thing that makes markdown useful.

And looking simple with minimal formatting is the second thing. This idea taps on that second thing.

Re:Markdown.css – Make HTML look like plain-text markdown by lisper on Thursday December 29, 2016 @08:53AM (#13277232)
If that's your goal, and your source is already in HTML, then the best solution is no CSS at all.
Re:Markdown.css – Make HTML look like plain-text markdown by dannypgh on Thursday December 29, 2016 @09:09AM (#13277316)
Isn't the default styling of HTML in browsers mostly just due to historical accidents?
Re:Markdown.css – Make HTML look like plain-text markdown by lisper on Thursday December 29, 2016 @04:47PM (#13280437)
Probably. So?
Re:Markdown.css – Make HTML look like plain-text markdown by chx on Thursday December 29, 2016 @01:31AM (#13275996)
It only needs a little JS to make it work, though. You just need to manipulate the selected text as described here http://stackoverflow.com/a/36582615/308851 and https://github.com/niklasvh/jquery.plugin.clipboard here.
Re:Markdown.css – Make HTML look like plain-text markdown by blowski on Thursday December 29, 2016 @05:11AM (#13276570)
So

1. Take some HTML

2. Use CSS to make it look like Markdown

3. Use JavaScript to make it behave like Markdown.

Why not skip step 2?

Re:Markdown.css – Make HTML look like plain-text markdown by chx on Thursday December 29, 2016 @05:23AM (#13276609)
Because it's masterful to use CSS for this and the required JS is simple and generic.
Re:Markdown.css – Make HTML look like plain-text markdown by lisper on Thursday December 29, 2016 @05:56PM (#13280946)
Rewriting TeX in Brianfuck would be masterful too. That doesn't make it a good idea.
Re:Markdown.css – Make HTML look like plain-text markdown by clusmore on Wednesday December 28, 2016 @08:39PM (#13275122)
Why does everything need to serve a purpose? I can believe the author wrote this just "Because I Can", which is a perfectly good reason to me. Most stuff I work on in my free time, I do just for me. If I think anybody else might be interested in it, not necessarily because it's useful but just because it's interesting, then I share it.

Edit to add: Not suggesting that you think it needs to serve a purpose, this just felt like the most appropriate thread to add my comment to.

Re:Markdown.css – Make HTML look like plain-text markdown by Retr0spectrum on Wednesday December 28, 2016 @07:24PM (#13274849)
I agree that this is cool, but it doesn't usefully convert back to plaintext, since the pseudo-elements don't get selected with the rest of the text if you try to copy and paste.
Re:Markdown.css – Make HTML look like plain-text markdown by eridius on Wednesday December 28, 2016 @07:27PM (#13274858)
Cute. But is there any way to make the markdown formatting text actually selectable/copyable? Right now I can't select it, and if I copy the text surrounding it, the markdown formatting simply vanishes.
Re:Markdown.css – Make HTML look like plain-text markdown by chx on Thursday December 29, 2016 @01:42AM (#13276037)
There is. You just need to manipulate the selected text as described here http://stackoverflow.com/a/36582615/308851 and https://github.com/niklasvh/jquery.plugin.clipboard here.
Re:Markdown.css – Make HTML look like plain-text markdown by eatonphil on Wednesday December 28, 2016 @09:17PM (#13275262)
I was quite surprised to learn about the attr function [0] that allows you to query the selected element's attributes, but it's actually been around for a while now and is supported by most (/ all?) browsers. Pretty nifty.

[0] https://developer.mozilla.org/en-US/docs/Web/CSS/attr

Re:Markdown.css – Make HTML look like plain-text markdown by Retr0spectrum on Wednesday December 28, 2016 @07:28PM (#13274861)
As the author notes, there's a similar project here: https://fvsch.github.io/remarkdown/

Personally, I'd consider using this for projects where I want the plaintext aesthetic, but also with the semantic elements that HTML provides for accessibility/interactivity purposes.

Re:Markdown.css – Make HTML look like plain-text markdown by mrcoles on Thursday December 29, 2016 @02:50PM (#13279563)
Lol, loving all the comments asking what the usecase is or pointing out how it’s not functional.

Here are some other things I’ve built in the past because the code and/or the idea was interesting to me: http://mrcoles.com/failed-projects/ | http://mrcoles.com/dragondrop/ | http://mrcoles.com/tetris/ | http://mrcoles.com/low-res-paint/ | http://mrcoles.com/piano/ — don’t bother asking for a usecase ;)

Re:Markdown.css – Make HTML look like plain-text markdown by TuringTest on Thursday December 29, 2016 @09:07AM (#13277305)
What I don't get is why Markdown is always displayed as plain text, when it's supposedly a format to represent styling. Why can't we have a version of Markdown that gets syntax highlighting according to the actual written markup, without hiding the markup code? I.e. making identical the "code" form and the final "rendered" form.

For example, writing " * this is highlighted * " would be shown as " * this is highlighted * ".

Edit: I've just found http://hackcss.com/ in the comments below, which seems to get it and does what I've explained above, highlighting headers and code with a bold, darker font.

Re:Markdown.css – Make HTML look like plain-text markdown by dejawu on Thursday December 29, 2016 @09:43AM (#13277478)
Some newer Markdown editors will style the raw Markdown in addition to providing the rendered form, such as StackEdit[1] or Nanote[2] (my own work).

[1] https://stackedit.io/editor

[2] https://nanote.co

Re:Markdown.css – Make HTML look like plain-text markdown by akavel on Thursday December 29, 2016 @01:01PM (#13278821)
For a desktop editor, see: http://www.typora.io/ (non affiliated, I just like it, wanted to write something similar)
Re:Markdown.css – Make HTML look like plain-text markdown by TuringTest on Tuesday January 03, 2017 @04:52AM (#13308071)
Yes, Typora's live preview is more or less what I was thinking, showing the markup just for the item rigth below the cursor.

I'd still add a mode like Microsoft Word's "show formatting marks", so that the user can decide whether to see the full markdown text or only the word or line being edited.

Re:Markdown.css – Make HTML look like plain-text markdown by shoover on Thursday December 29, 2016 @09:27AM (#13277404)
Are you asking for this functionality in the editor or browser or something else? Editors do highlight text as you describe, at least in Emacs in markdown-mode and org-mode. Still, my experiments with variable width fonts in these modes have never stuck. As soon as you need to align anything like a header rule, source code, or table, you need a fixed width font. Then it comes down to whether the mode supports customizing that particular face.
Re:Markdown.css – Make HTML look like plain-text markdown by cocktailpeanuts on Thursday December 29, 2016 @12:35AM (#13275818)
I for one, applaud this type of experiment over the next new CSS grid framework that does the same thing as thousand others that came before.
Re:Markdown.css – Make HTML look like plain-text markdown by nkjoep on Thursday December 29, 2016 @07:00AM (#13276856)
Yes! and just for the record I wrote a similar thing 3 years ago https://github.com/NKjoep/i-love-markdown.css
Re:Markdown.css – Make HTML look like plain-text markdown by notgood on Wednesday December 28, 2016 @07:04PM (#13274767)
It would be way more useful if you could copy the "markdown version" (as a quick way to create Markdown files), but a lot of characters such as "##" can't be selected/copied because its using the css rule "content" to create them[0].

Unfortunately a proper solution for this would need to modify the HTML (JavaScript) to add such characters.

[0] http://stackoverflow.com/questions/19914349/how-can-i-make-g...

Re:Markdown.css – Make HTML look like plain-text markdown by rat87 on Thursday December 29, 2016 @05:06AM (#13276557)
Why are css content characters not copy/pasteable?

That seems broken.

Re:Markdown.css – Make HTML look like plain-text markdown by oneeyedpigeon on Thursday December 29, 2016 @10:30AM (#13277766)
Probably because they should only be used for 'decoration' rather than actual content - this is css, after all.
Re:Markdown.css – Make HTML look like plain-text markdown by leeoniya on Thursday December 29, 2016 @12:57AM (#13275889)
or to actually convert HTML to markdown: https://github.com/leeoniya/reMarked.js

disclaimer: mine

Re:Markdown.css – Make HTML look like plain-text markdown by bambax on Thursday December 29, 2016 @03:54AM (#13276366)
or to convert rich text to markdown: http://markitdown.medusis.com

(same disclaimer!)

Re:Markdown.css – Make HTML look like plain-text markdown by duck on Wednesday December 28, 2016 @10:22PM (#13275447)
Another similar project is http://hackcss.com/ (which was inspired by this one).
Re:Markdown.css – Make HTML look like plain-text markdown by sergiotapia on Wednesday December 28, 2016 @07:42PM (#13274919)
Shame you can't select all the selectors for markdown.
Re:Markdown.css – Make HTML look like plain-text markdown by alanh on Wednesday December 28, 2016 @10:13PM (#13275414)
IIRC, Firefox used to have this behavior. It no longer does.
Re:Markdown.css – Make HTML look like plain-text markdown by mcaruso on Thursday December 29, 2016 @08:28AM (#13277121)
Could be wrong here, but I don't think it did. I remember when the feature was first implemented, and I thought that the fact that you could not select pseudotext was just a temporary thing while they finished their implementation. Unfortunately it never happened.
Re:Markdown.css – Make HTML look like plain-text markdown by dom0 on Thursday December 29, 2016 @12:17PM (#13278498)
Opera did this iirc
Re:Markdown.css – Make HTML look like plain-text markdown by alanh on Thursday December 29, 2016 @03:51PM (#13280021)
That was probably it. I knew one of them did.
Re:Markdown.css – Make HTML look like plain-text markdown by nerdponx on Wednesday December 28, 2016 @08:32PM (#13275097)
I ask about Pandoc in every Markdown thread, but only because I'm interested in the success of Markdown.

That said... why not Pandoc? Just too heavyweight for a browser?

Re:Markdown.css – Make HTML look like plain-text markdown by nathancahill on Wednesday December 28, 2016 @10:01PM (#13275390)
Is there a JS port? I <3 Pandoc and use it to publish projects to PyPI and Github with one readme.
Re:Markdown.css – Make HTML look like plain-text markdown by nerdponx on Thursday December 29, 2016 @08:25AM (#13277113)
No but that would be very interesting.
Re:Markdown.css – Make HTML look like plain-text markdown by daurnimator on Wednesday December 28, 2016 @10:50PM (#13275520)
Not sure how pandoc is related to the OP
Re:Markdown.css – Make HTML look like plain-text markdown by nerdponx on Thursday December 29, 2016 @08:24AM (#13277110)
It converts HTML to Markdown.
Re:Markdown.css – Make HTML look like plain-text markdown by christianmunoz on Wednesday December 28, 2016 @06:57PM (#13274727)
I'm curious on your intended or expected use cases?
Re:Markdown.css – Make HTML look like plain-text markdown by Aardwolf on Thursday December 29, 2016 @05:50AM (#13276677)
I don't understand the love for markdown. The problem is it ignores a single line break. Comments on hn and reddit do that too. Result: people posting a list of things intended to be one per line, instead become concatenated on 1 line with spaces. I know there is a way, two spaces at end of previous line. That method is hard to maintain if editing, has nothing to do with plain text, easy to forget, and most don't know.

It should turn a line break into br, then markdown would be alright.

Re:Markdown.css – Make HTML look like plain-text markdown by pvdebbe on Thursday December 29, 2016 @06:39AM (#13276803)
With an 's#\n#<br/>#g' substitution you now have to choose between readable source text (lines < 80 characters) and responsive rendered HTML (lines don't break until boundaries).
Re:Markdown.css – Make HTML look like plain-text markdown by Aardwolf on Thursday December 29, 2016 @06:59AM (#13276852)
Valid point for in text editors and code.

The problem is many input fields in websites trending to use it now. I think BBCode was more suitable for that. Markdown is easier than BBCode on one hand, but the newline thing ruins it for simple replies to posts.

Re:Markdown.css – Make HTML look like plain-text markdown by tejasmanohar on Wednesday December 28, 2016 @11:29PM (#13275631)
What's the use case? I'd rather go the other way around... Markdown -> HTML