Five easy pieces #3: Mark this

https://learninghub.kx.com/forums/topic/five-easy-pieces-3-mark-this

First stage: file smile.txt

 

The All-American Smile In a way he was like the land itself. Everything came to him too easily. But at least he knew it, and from time to time he worried about being a phoney.

 

Write a single expression that reads the file, follows Markdown rules, and returns an HTML document as a string, e.g.

 

  
     

The All-American Smile

In a way he was like the land itself. Everything came to him too easily.

But at least he knew it, and from time to time he worried about being a phoney.

 

Hints: The .h namespace and File Binary; however .h.ht is not a solution.

 

Not tempted yet? Lets make it easier and harder.

  • Easier: file lines have no trailing spaces.
  • Harder: let your expression contain no more than one reference to .h.htc.

Oh yes. Now were having fun.

 

{.h.htc[y;x]}/[.h.text"nn"vs"c"$ read1 `:smile.md;`body`html]

 

Second stage: smile2.md

 

The All-American Smile In a way he was like the land itself. Everything came to him too easily. But at least he knew it, and from time to time he worried about being a phoney.

 

Output:

 

  
    

The All-American Smile

In a way he was like the land itself. Everything came to him too easily.

But at least he knew it, and from time to time he worried about being a phoney.

 

 

A few different variations:

-1 {i:where ""~/:x;raze "

",@[x;i;:;count[i]#enlist "

"],"

"} read0 `:smile.txt -1"

",,[;"

"] ssr[;"n";""] "

" sv "nn" vs`char$read1`:smile.txt -1"

",ssr["

"sv"nn"vs`char$read1`:smile.txt;"n";""],"

" -1{.h.htc[y;x]}over(ssr["

"sv"nn"vs`char$read1`:smile.txt;"n";""];`p;`body;`html) -1({.h.htc[y;x]})(ssr["

"sv"nn"vs`char$read1`:smile.txt;"n";""];`p;`body;`html)