@dimerapp/dfile
Dimer file to convert it to markdown and check for linting errors
Last updated 8 months ago by virk .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @dimerapp/dfile 
SYNC missed versions from official npm registry.
Dimer App

Dimer is an open source project and CMS to help you publish your documentation online.


We believe every project/product is incomplete without documentation.
We want to help you publish user facing documentation, without worrying about tools or code to write.


Dimer Dfile

Converts the markdown file to vFile

travis-image npm-image

This module will convert the markdown file by reading it from the disk, and also reports the errors via vfile interface.

Installation

npm i --save-dev @dimerapp/dfile

# yarn
yarn add @dimerapp/dfile

Usage

const Dfile = require('@dimerapp/dfile')

const file = new Dfile(join(__dirname, 'readme.md'))
await file.parse()

if (file.messages) {
  // has errors
}

// JSON AST
file.contents

Computing base name

You can instruct dFile to compute the base name of the file from a given directory by providing the base path

const Dfile = require('@dimerapp/dfile')
const docsDir = join(__dirname, 'docs')
const filePath = join(docsDir, 'getting-started/intro.md')

const file = new Dfile(filePath, docsDir)
console.log(file.baseName) // getting-started/intro.md

Extend Markdown library

The @dimerapp/markdown library exposes an option to add macros. This library also exposes the library as Markdown property.

Dfile.Markdown.addMacro('button', callback)

API

The following properties/methods are available on the file instance.

constructor(filePath, [basePath], [markdownOptions])

new Dfile(filePath, basePath, {
  async onUrl () {
  },
  title: 'Custom title',
  skipToc: false
})

parse()

Parse the file by reading it from the disk.

const file = new Dfile(join(__dirname, 'readme.md'))
await file.parse()

fatalMessage(message, ruleId)

Add a new fatal message with rule id

file.fatalMessage('Missing title', 'missing-title')

warningMessage(message, ruleId)

Add a new warning with rule id

file.warningMessage('Missing title', 'missing-title')

contents

File JSON AST

file.contents

messages

File error messages. The messages fatal property are hard errors.

file.messages

fatalMessages

Returns an array of fatal messages.

file.fatalMessages

warningMessages

Returns an array of warnings.

file.warningMessages

filePath

File absolute path

file.filePath

metaData

File yaml front matter meta data

file.metaData

toJSON()

Returns the JSON representation of the file

file.toJSON()

Change log

The change log can be found in the CHANGELOG.md file.

Contributing

Everyone is welcome to contribute. Please take a moment to review the contributing guidelines.

Authors & License

thetutlage and contributors.

MIT License, see the included MIT file.

Current Tags

  • 1.1.5                                ...           latest (8 months ago)

18 Versions

  • 1.1.5                                ...           8 months ago
  • 1.1.4                                ...           8 months ago
  • 1.1.3                                ...           2 years ago
  • 1.1.2                                ...           2 years ago
  • 1.1.1                                ...           2 years ago
  • 1.1.0                                ...           2 years ago
  • 1.0.11                                ...           2 years ago
  • 1.0.10                                ...           2 years ago
  • 1.0.9                                ...           2 years ago
  • 1.0.8                                ...           2 years ago
  • 1.0.7                                ...           2 years ago
  • 1.0.6                                ...           2 years ago
  • 1.0.5                                ...           2 years ago
  • 1.0.4                                ...           2 years ago
  • 1.0.3                                ...           2 years ago
  • 1.0.2                                ...           2 years ago
  • 1.0.1                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (5)
Dev Dependencies (10)

Copyright 2014 - 2016 © taobao.org |