npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@yozora/gatsby-transformer

v2.2.0

Published

Transform markdown files to Yozora AST

Downloads

43

Readme

A gatsby plugin for transforming markdown files to markdown ast through Yozora Parser, Inspired by gatsby-transformer-remark.

Install

This plugin depends on Yozora Parser, as of now, you can choose @yozora/parser (Recommend) or @yozora/parser-gfm or @yozora/parser-gfm-ex.

  • npm

    npm install @yozora/gatsby-transformer @yozora/parser --save-dev
  • yarn

    yarn add @yozora/gatsby-transformer @yozora/parser --dev

Usage

Add configs in gatsby-config.mjs:

// gatsby-config.mjs
import { YozoraParser } = from '@yozora/parser'

module.exports = {
  plugins: [
    {
      resolve: '@yozora/gatsby-transformer',
      options: {
        parser: new YozoraParser(),
        preferFootnoteReferences: true,
        frontmatter: {
          excerpt_separator: '<!-- more -->',
        }
      }
    }
  ]
}

Options

Name | Required | Default :---------------------------|:----------|:----------- parser | true | - preferFootnoteReferences | false | false presetDefinitions | false | - presetFootnoteDefinitions | false | - headingIdentifierPrefix | false | heading- footnoteIdentifierPrefix | false | footnote- shouldStripChineseChars | false | false wordsPerMinute | false | 80 frontmatter | false | - plugins | false | -

  • parser: A yozora parser.

  • preferFootnoteReferences: Replace footnotes into footnote references and footnote reference definitions.

  • presetDefinitions: Preset link reference definitions.

  • presetFootnoteDefinitions: Preset footnote reference definitions.

  • headingIdentifierPrefix: The identifier prefix of the headings that constitutes the toc (Table of Content).

  • footnoteIdentifierPrefix: The identifier prefix of the footnote references and footnote reference definitions.

  • shouldStripChineseChars: Whether to remove line end between two chinese characters.

  • wordsPerMinute: The number of words read per minute.

  • frontmatter: Options for gray-matter.

  • plugins: Plugins of @yozora/gatsby-transformer, similar with the plugins option of gatsby-transformer-remark.

    /**
    * Api passed to the options.plugins
    */
    export interface AstMutateApi {
      files: Node[]
      markdownNode: Node
      markdownAST: Root
      pathPrefix: string
      getNode(id: string): Node
      reporter: Reporter
      cache: GatsbyCache
    }
    
    function plugin(api: AstMutateApi, pluginOptions: any): void
    • api: passed by @yozora/gatsby-transformer

    • pluginOptions: defined in gatsby-config.js, such as the highlighted line in the following code (line eight)

      const presetDefinitions = []
      const presetFootnoteDefinitions = []
      
      {
        resolve: '@yozora/gatsby-transformer',
        options: {
          parser: new YozoraParser({
            defaultParseOptions: {
              shouldReservePosition: false,
              presetDefinitions,
              presetFootnoteDefinitions,
            },
          }),
          presetDefinitions,
          presetFootnoteDefinitions,
          preferFootnoteReferences: true,
          shouldStripChineseCharacters: true,
          frontmatter: {
            excerpt_separator: '<!-- more -->',
          },
          plugins: [
            {
              resolve: '@yozora/gatsby-images',
              options: {},    // this is the pluginOptions.
            },
          ],
        },
      }

Features

  • Code (Yozora Code node) support sourcefile and sourceline meta options, for example:

    ```cpp sourcefile="./solution.cpp" sourceline="2-8"
    ```

    In the above code, sourcefile specifies the source file location, then @yozora/gatsby-transformer will read the solution.cpp under that directory where the current markdown file is located. If this file (solution.cpp) exists, it will read the contents of the file. sourceline specifies which lines will be intercepted (in the above example, intercept lines 2-8 and 10), these lines will be concat and used as the value of the Code node.

FAQ

Related