# markdownserver

> Simple markdown server with code syntax highlighting

Latest version **2.2.3** (published 2017-01-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install markdownserver
pnpm add markdownserver
yarn add markdownserver
bun add markdownserver
```

Provides the command `markdownserver`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.2.3 |
| Published | 2017-01-31 |
| First published | 2016-03-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 17 |
| Known vulnerabilities | 0 (+4 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Superzadeh |
| Maintainers | superzadeh |

## Links

- npm: https://www.npmjs.com/package/markdownserver
- Repository: https://github.com/superzadeh/MarkdownServer
- Homepage: https://github.com/superzadeh/MarkdownServer#readme
- Issues: https://github.com/superzadeh/MarkdownServer/issues
- npm.io page: https://npm.io/package/markdownserver

## Dependencies (17)

- [jade](https://npm.io/package/jade.md) ^1.11.0
- [snyk](https://npm.io/package/snyk.md) ^1.24.6
- [jquery](https://npm.io/package/jquery.md) ^3.0.0
- [marked](https://npm.io/package/marked.md) ^0.3.5
- [morgan](https://npm.io/package/morgan.md) ^1.6.1
- [express](https://npm.io/package/express.md) ^4.13.4
- [raphael](https://npm.io/package/raphael.md) ^2.2.7
- [request](https://npm.io/package/request.md) ^2.79.0
- [bluebird](https://npm.io/package/bluebird.md) ^3.4.6
- [httpntlm](https://npm.io/package/httpntlm.md) ^1.7.3
- [istanbul](https://npm.io/package/istanbul.md) ^0.4.5
- [commander](https://npm.io/package/commander.md) ^2.9.0
- [underscore](https://npm.io/package/underscore.md) ^1.8.3
- [highlightjs](https://npm.io/package/highlightjs.md) ^8.7.0
- [semantic-ui](https://npm.io/package/semantic-ui.md) ^2.2.6
- [errorhandler](https://npm.io/package/errorhandler.md) ^1.5.0
- [markdown-toc](https://npm.io/package/markdown-toc.md) ^0.12.3

## Recent versions

- 2.2.3 (latest) — 2017-01-31
- 2.2.2 — 2016-08-09
- 2.2.1 — 2016-08-09
- 2.2.0 — 2016-08-05
- 2.1.2 — 2016-06-22
- 2.1.1 — 2016-06-07
- 2.1.0 — 2016-06-07
- 2.0.0 — 2016-04-20
- 1.0.1 — 2016-03-25
- 1.0.0 — 2016-03-25

## README

# Markdown Server

[![Build Status](https://travis-ci.org/superzadeh/MarkdownServer.svg?branch=master)](https://travis-ci.org/superzadeh/MarkdownServer)
[![Coverage Status](https://coveralls.io/repos/github/superzadeh/MarkdownServer/badge.svg?branch=master)](https://coveralls.io/github/superzadeh/MarkdownServer?branch=master)

A simple HTTP server that serves markdown files.

## Supported Syntax

- [GFM (Github Flavor Markdown)](https://guides.github.com/features/mastering-markdown/) is partially supported, only task lists are not done yet (and any feature directly related to Github is not integrated, such as mentions,SHA References etc.)
- Code is highlighted using [HighlightJS](https://highlightjs.org/)
- Diagrams and rendered using [js-sequence-diagrams](https://bramp.github.io/js-sequence-diagrams/)

If you find any issues, please report them in the [issues](https://github.com/superzadeh/MarkdownServer/issues) section of this repo. 

## Installation

Install dependencies, build, then start the development server with `gulp`.

```bash
git clone https://github.com/superzadeh/MarkdownServer
cd MarkdownServer
npm install gulp -g
npm install
gulp build
gulp
```

Drop files in the ./markdown folder, and access them by file name without the extension.

If you need to serve images, you can drop them in the `public/images` folder. To reference them in a markdown document, simply use `images/your_image.png` as source.

```bash
http://localhost:3337/example
```

### Gulp tasks

The following gulp tasks are available:

| Task name         | Description |
|-------------------|-------------|
| gulp              | run the `serve` task |
| gulp serve        | starts serving using browser sync and watches for views/markdown changes |
| gulp build        | builds semantic UI and deploys dependencies to the `public/dist` folder |
| gulp build-serve  | runs `build` and `serve` |

The `serve` task (which is also the default `gulp` task) will start nodemon to automatically restart the server if server code changes, 
as well as browsersync to refresh if the views or markdown files are updated.
This means that you can also use this as a live previewer of your markdown files.

## Hosting on IIS

This server comes with a preconfigured web.config file as well as an issnode.yml.
To host this site in IIS:

* Clone/copy the content of this repo in a IIS WebSite.
* Install [iisnode](https://github.com/tjanczuk/iisnode)
* Make sure you application's pool identity has read/write permissions to the site's folder
* The application pool can be in .NET 2 and does not need to enable 32 bits applications
* Run `npm install` to install dependencies
* Customize the default `web.config` (enable authentication, etc.)
* Customize the default `issnode.yml` file (disable dev errors, etc.)

## Configuration

### Local files

By default, all files within the folder ./markdown will be served. This folder can be changed by 
setting the environment variable `MARKDOWN_FOLDER`.

### External files

To load files from an external URL, set the following environment variable:

* MARKDOWN_EXTERNAL_ROOT

You can then access the files using `http://localhost:3337/external/filename`, where the file loaded
will be located at MARKDOWN_EXTERNAL_ROOT/filename.md. Example:

* If MARKDOWN_EXTERNAL_ROOT is `http://google.com/`, then `http://localhost:3337/external/filename` will load the 
  file at the url `http://google.com/filename.md`.

Note that for IIS hosting, environment variables can be set using appSettings in the webconfig where the key is
the name of the environment variable and the value is its value.

### Authentication

URL requests for external files can use NTLM authentication. To do so, set the `NTLM_DOMAIN` environment variables and run the command 
line tool provided with markdown server to set the username and password that should be used for the NTLM authentication.
These credentials will be encrypted and stored in a credentials.json file at the root of the server:

    npm install markdownserver -g
    markdownserver -u username -p password


## Contributions

Pull requests are welcome, as long you keep this thing simple. I want it to be and remain a very 
simple solution to serve markdown files.

### Running tests

You can run tests using `npm test`. To run the tests as well as a coverage analysis, use `npm run test-cover`.
There is also a watchable task `npm run test-watch`.

Note that the coverage threshold is at 90%, so make sure your stay above it if you make changes.

### TODO

* [X] Implement NTLM tests
* [X] Add bluebird and promisify all the things
* [X] Improve the sidebar: make it collapsible and make the content good looking
* [X] Expose the table of content of a local file through a JSON API
* [X] Expose the table of content of an external file through a JSON API
* [ ] Add a search feature
* [ ] Create a review workflow with ability to add comments
* [ ] Add FTP support
* [ ] Add an administration UI (or CLI client) to setup NTLM, External & FTP parameters, as well as select the default highlighter theme
* [X] Provide a more secure way to store credentials (still not ideal, provide a proxy based solution for auth)
* [ ] Allow users to upload new markdown files
* [ ] Tune performances
* [ ] Reorganize mocks and nocks to make them easier to reuse/maintain 

### Visual Studio Code

This project is optimized for edition within [Visual Studio Code](https://code.visualstudio.com/).
make sure to run `tsd install` to retrieve all the typings. This will provide you with
Intellisense for the frameworks used in this project.

    npm install tsd -g
    tsd install

I also recommend to use the [Beautify](https://marketplace.visualstudio.com/items?itemName=HookyQR.beautify)
extension that will help ensure the same coding style automatically (beautify on save is enabled).

---
_Source: https://npm.io/package/markdownserver · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
