1
1
mirror of https://github.com/aelve/guide.git synced 2024-12-23 04:42:24 +03:00

Link to Markdown everywhere

This commit is contained in:
Artyom 2016-05-02 21:27:49 +03:00
parent 393b4a1b19
commit 2c6046b08f
6 changed files with 86 additions and 13 deletions

View File

@ -374,8 +374,13 @@ makeTraitEditor =
switchSection(traitNode, "editable");
return false; };
cancelBtn = $("<span>", {"class":"text-button"})[0];
markdown = $("<a>", {
"href" : "/markdown",
"target" : "_blank",
"style" : "float:right",
"text" : "Markdown" })[0];
$(cancelBtn).append(a);
$(sectionNode).append(area, br, cancelBtn);
$(sectionNode).append(area, br, cancelBtn, markdown);
|]
-- | Dynamically creates a 'View.markdownEdito' (but specifically for item
@ -413,10 +418,14 @@ makeItemNotesEditor =
monospace.onchange = function () {
setMonospace(area, monospace.checked); };
monospaceLabel = $("<label>")[0];
markdown = $("<a>", {
"href" : "/markdown",
"target" : "_blank",
"text" : "Markdown" })[0];
$(monospaceLabel).append(monospace, "monospace editor");
$(sectionNode).append(
area, saveBtn, $(space), cancelBtn, $(space),
"Markdown", $(space), monospaceLabel);
markdown, $(space), monospaceLabel);
|]
-- | Create a new category and redirect to it (or redirect to an old category

View File

@ -677,6 +677,10 @@ main = do
Spock.get "unwritten-rules" $ do
lucidWithConfig $ renderUnwrittenRules
-- Markdown help
Spock.get "markdown" $ do
lucidWithConfig $ renderMarkdownHelp
-- Haskell
Spock.subcomponent "haskell" $ do
Spock.get root $ do

View File

@ -19,6 +19,7 @@ module View
renderDonate,
renderCategoryPage,
renderUnwrittenRules,
renderMarkdownHelp,
renderSearchResults,
-- * Tracking
@ -428,6 +429,12 @@ renderUnwrittenRules = wrapPage "Unwritten rules" $ do
toHtml . renderMarkdownBlock =<<
liftIO (T.readFile "static/unwritten-rules.md")
renderMarkdownHelp
:: (MonadIO m, MonadRandom m, MonadReader Config m) => HtmlT m ()
renderMarkdownHelp = wrapPage "Markdown" $ do
toHtml . renderMarkdownBlock =<<
liftIO (T.readFile "static/markdown.md")
-- Include all the necessary things
wrapPage
:: (MonadIO m, MonadRandom m, MonadReader Config m)
@ -1097,7 +1104,7 @@ markdownEditor attr (view mdText -> s) submit cancel = do
JS.assign val s <>
cancel
emptySpan "6px"
"Markdown"
a_ [href_ "/markdown", target_ "_blank"] "Markdown"
emptySpan "6px"
-- TODO: this jumps around when there's a lot of text, need to somehow
-- prevent jumping (and in JS.makeItemNotesEditor too)
@ -1127,6 +1134,7 @@ smallMarkdownEditor attr (view mdText -> s) submit mbCancel = do
textButton "cancel" $
JS.assign val s <>
cancel
a_ [href_ "/markdown", target_ "_blank", style_ "float:right"] "Markdown"
thisNode :: MonadRandom m => HtmlT m JQuerySelector
thisNode = do

View File

@ -6,12 +6,3 @@ The most important rule is: **it's collaborative notes, not Wikipedia**. This im
> **cons:** buggy (see an example on my Github, here's the link)
Second, you should write as if you were writing for a friend. If a friend asks you about X, you don't go on X's site and copy the standard “X is a powerful modern framework blah blah blah” blurb well, don't do it here either. Here is the whole version of the [unwritten rules](/unwritten-rules), except that they are written and aren't rules.
Markdown is supported in most places. 2 noteworthy features: you can write `[pkg](@hk)` to get a link to package `pkg` on Hackage (the full list of shortcuts is [here](https://hackage.haskell.org/package/shortcut-links/docs/ShortcutLinks-All.html), and you can mark snippets of code with `repl` to show that they come from GHCi:
~~~~
~~~ hs repl
> 2+2
4
~~~
~~~~

59
static/markdown.md Normal file
View File

@ -0,0 +1,59 @@
# Markdown
Markdown is supported in most places; inline Markdown in pros/cons (i.e. you can't create lists, paragraphs, etc) and ordinary Markdown elsewhere. If you haven't written Markdown before, see [this reference][Commonmark ref].
[Commonmark ref]: http://commonmark.org/help/
## Custom features
You can write `[pkg](@hk)` to get a link to package `pkg` on Hackage (the full list of shortcuts is [here][shortcuts]).
[shortcuts]: https://hackage.haskell.org/package/shortcut-links/docs/ShortcutLinks-All.html
If you mark snippets of code with `repl` (to show that they come from GHCi), they will display differently:
<table width="100%"><tr><td width="45%">
~~~~
~~~ hs repl
> 2+2
4
~~~
~~~~
</td><td width="10%">
<div style="text-align:center;font-size:400%"></div>
</td><td width="45%">
~~~ hs repl
> 2+2
4
~~~
</td></tr></table>
If something doesn't come from GHCi, but is still Haskell code, use `hs` or `haskell` (other languages are supported too):
<table width="100%"><tr><td width="45%">
~~~~
~~~ hs
t :: Bool
t = True
~~~
~~~~
</td><td width="10%">
<div style="text-align:center;font-size: 400%"></div>
</td><td width="45%">
~~~ hs
t :: Bool
t = True
~~~
</td></tr></table>

View File

@ -2,11 +2,13 @@
If you disagree with any of these “rules”, ignore them! I don't think they are right, I just think they are better than what people would be doing otherwise if they didn't have any opinions on the matter.
For custom Markdown features we have, see [here](/markdown).
## What to include
Sort things by importance and don't try to write *everything*. The problem is that when you see 2 columns titled “pros” and “cons”, it makes people want to try and come up with as many pros/cons as possible (well, actually I don't know about *people*, but it does happen to me all the time, so it probably happens to others too). This should be avoided at all costs. Same with items themselves (e.g. libraries) don't list all related libraries, list all libraries that could conceivably be chosen. The test is simple: if you can't say under what conditions a person would choose A over B, and B is already on the list, don't add A. I can very well relate to the vague feeling of “but A deserves to be mentioned too”, but still, don't.
On the other hand, there's another problem that should somehow be avoided. Let's take the section about books RWH and LYAH are often recommended to people, but there's Haskell Programming From First Principles (that book at <haskellbook.com>) and it's regarded to be Totally Better Than LYAH And RWH Put Together. Even despite the fact that the former 2 are free and the latter one isn't, all 3 books still have to be mentioned otherwise, how is the reader going to know that LYAH was omitted because it's bad and not because everyone forgot to write about it? That's the problem that comes up very often, with lists like [What I Wish I Knew When Learning Haskell](http://dev.stephendiehl.com/hask/) and [State Of The Haskell Ecosystem](https://github.com/Gabriel439/post-rfc/blob/master/sotu.md) there are people who wouldn't trust them not because they don't trust the author's good intentions, but because they are afraid that the author simply didn't list something worth mentioning. This leads to endless Google searches and traversals of related Hackage categories (and there are way too many packages on Hackage).
On the other hand, there's another problem that should somehow be avoided. Let's take the section about books RWH and LYAH are often recommended to people, but there's Haskell Programming From First Principles (that book at [haskellbook.com](http://haskellbook.com)) and it's regarded to be Totally Better Than LYAH And RWH Put Together. Even despite the fact that the former 2 are free and the latter one isn't, all 3 books still have to be mentioned otherwise, how is the reader going to know that LYAH was omitted because it's bad and not because everyone forgot to write about it? That's the problem that comes up very often, with lists like [What I Wish I Knew When Learning Haskell](http://dev.stephendiehl.com/hask/) and [State Of The Haskell Ecosystem](https://github.com/Gabriel439/post-rfc/blob/master/sotu.md) there are people who wouldn't trust them not because they don't trust the author's good intentions, but because they are afraid that the author simply didn't list something worth mentioning. This leads to endless Google searches and traversals of related Hackage categories (and there are way too many packages on Hackage).
In a nutshell: