Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ordbok/core

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ordbok/core

Dictionary system

  • 0.2.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

ORDBOK Core

Core system to create a dictionary out of Markdown files.

How to use

The following example shows a Markdown source file named english.md:

English
=======

Translation: English ; the English

Grammar:     Noun ; Neuter

New Norwegian
=============

Translation: engelsk ; engelsken

Grammar:     Noun ; Masculine

The following example takes a Markdown source folder to build dictionary files into a ./build/dictionary folder:

$ npx ordbok-assembler ./markdown ./build/dictionary

The following TypeScript code uses the dictionary files to find a translation:

import { Dictionary, Utilities } from `@ordbok/core`;

const myDictionary = new Dictionary('build/dictionary');

const theEntry = myDictionary.loadEntry('English');

console.log(theEntry[Utilities.getKey('New Norwegian')].translation); // = engelsk, engelsken
console.log(theEntry[Utilities.getKey('New Norwegian')].grammar); // = Noun, Masculine

Plugins

Create a ordbok.json in your project to register custom plugins for the assembling process. You can specify node modules and folders:

{
    "plugins": [
        "@ordbok/index-plugin",
        "../tools/custom-plugin"
    ]
}

If you like to create a custom plugin yourself, create a folder or package with a ordbok-plugin.js file somewhere inside. Here is how the corresponding TypeScript file looks like:

const { IMarkdownPage, IPlugin, Markdown } = require('@ordbok/core/internals');

export const ordbokPlugin: IPlugin = {
    onAssembling: (sourceFolder: string, targetFolder: string) => {},
    onReadFile: (sourceFile: string, markdown: Markdown) => {},
    onWriteFile: (targetFile: string, markdownPage: IMarkdownPage) => {},
    onAssembled: () => {}
};

Keywords

FAQs

Package last updated on 27 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc