Add part9

This commit is contained in:
Richard Feldman
2018-05-05 08:49:24 -04:00
parent edbbcacb7c
commit f89b1aa197
576 changed files with 79135 additions and 0 deletions

View File

@@ -0,0 +1 @@
elm-stuff

View File

@@ -0,0 +1,30 @@
Copyright (c) 2014, Evan Czaplicki
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Evan Czaplicki nor the names of other
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@@ -0,0 +1,38 @@
# Markdown in Elm
This package is for markdown parsing and rendering. It is based on the [marked][] project
which focuses on speed.
[marked]: https://github.com/chjj/marked
## Basic Usage
```elm
content : Html msg
content =
Markdown.toHtml [class "content"] """
# Apple Pie Recipe
1. Invent the universe.
2. Bake an apple pie.
"""
```
**Warning:** Calling `Markdown.toHtml` parses the whole block, so try not to
call it for no reason. In the `content` example above we only have to parse
the text once, but if we put it in a function we may be doing a lot of
unnecessary parsing.
## Code Blocks
For highlighting any code blocks, the package relies on the
[highlight.js](https://highlightjs.org/) project. So if you want to
see highlighting of code blocks in the rendering result, you need to
make sure that your page/app binds a version of that library
(supporting the languages you want to handle) to `window.hljs` in
Javascript. [This is how package.elm-lang.org does
that.](https://github.com/elm-lang/package.elm-lang.org/blob/e0b7aa4282038475612722ff7a57195866f8645b/backend/ServeFile.hs#L54)

View File

@@ -0,0 +1,18 @@
{
"version": "3.0.2",
"summary": "Fast markdown parsing and rendering",
"repository": "https://github.com/evancz/elm-markdown.git",
"license": "BSD3",
"source-directories": [
"src"
],
"exposed-modules": [
"Markdown"
],
"native-modules": true,
"dependencies": {
"elm-lang/core": "5.0.0 <= v < 6.0.0",
"elm-lang/html": "2.0.0 <= v < 3.0.0"
},
"elm-version": "0.18.0 <= v < 0.19.0"
}

View File

@@ -0,0 +1,104 @@
module Markdown exposing
( toHtml
, Options, defaultOptions, toHtmlWith
)
{-| A library for markdown parsing. This is just an Elm API built on top of the
[marked](https://github.com/chjj/marked) project which focuses on speed.
# Parsing Markdown
@docs toHtml
# Parsing with Custom Options
@docs Options, defaultOptions, toHtmlWith
-}
import Html exposing (Html, Attribute)
import Native.Markdown
{-| Turn a markdown string into an HTML element, using the `defaultOptions`.
recipe : Html msg
recipe =
Markdown.toHtml [class "recipe"] """
# Apple Pie Recipe
First, invent the universe. Then bake an apple pie.
"""
-}
toHtml : List (Attribute msg) -> String -> Html msg
toHtml attrs string =
Native.Markdown.toHtml defaultOptions attrs string
{-| Some parser options so you can tweak things for your particular case.
* `githubFlavored` &mdash; overall reasonable improvements on the original
markdown parser as described [here][gfm]. This includes stuff like [fenced
code blocks][fenced]. There are some odd parts though, such as [tables][]
and a setting to turn all newlines into newlines in the resulting output,
so there are settings to turn those on or off based on your preference.
* `defaultHighlighting` &mdash; a default language to use for code blocks that do
not have a language tag. So setting this to `Just "elm"` will treat all
unlabeled code blocks as Elm code. (This relies on [highlight.js][highlight]
as explained in the README [here](../#code-blocks).)
* `sanitize` &mdash; this determines if all HTML should be escaped. If you
are parsing user markdown or user input can somehow reach the markdown
parser, you should almost certainly turn on sanitation. If it is just you
writing markdown, turning sanitation off is a nice way to do some HTML
tricks if it is needed.
* `smartypants` &mdash; This will automatically upgrade quotes to the
prettier versions and turn dashes into [em dashes or en dashes][dash]
[gfm]: https://help.github.com/articles/github-flavored-markdown/
[fenced]: https://help.github.com/articles/github-flavored-markdown/#fenced-code-blocks
[tables]: https://help.github.com/articles/github-flavored-markdown/#tables
[highlight]: https://highlightjs.org/
[dash]: http://en.wikipedia.org/wiki/Dash
-}
type alias Options =
{ githubFlavored : Maybe { tables : Bool, breaks : Bool }
, defaultHighlighting : Maybe String
, sanitize : Bool
, smartypants : Bool
}
{-| The `Options` used by the `toElement` and `toHtml` functions.
{ githubFlavored = Just { tables = False, breaks = False }
, defaultHighlighting = Nothing
, sanitize = False
, smartypants = False
}
-}
defaultOptions : Options
defaultOptions =
{ githubFlavored = Just { tables = False, breaks = False }
, defaultHighlighting = Nothing
, sanitize = False
, smartypants = False
}
{-| Maybe you want to parse user input into markdown. To stop them from adding
`<script>` tags, you can use modified parsing options.
options : Options
options =
{ defaultOptions | sanitize = True }
toMarkdown : String -> Html
toMarkdown userInput =
Markdown.toHtmlWith options [] userInput
-}
toHtmlWith : Options -> List (Attribute msg) -> String -> Html msg
toHtmlWith =
Native.Markdown.toHtml

File diff suppressed because one or more lines are too long