[ WEBSITE | ISSUES | FORUM | CHANGELOG | NPM ]
This package implements BibTeX language support for the CodeMirror code editor.
The project page has more information, a number of examples and the documentation.
This code is released under an MIT license.
import { EditorView, basicSetup } from "codemirror";
import { bibtex } from "@citedrive/codemirror-lang-bibtex";
const view = new EditorView({
parent: document.body,
doc: `fmt.Println("hello world")`,
extensions: [basicSetup, bibtex()],
});-
bibtex(config?: {biblatex?: boolean, smartSuggest?: boolean, snippetRecs?: boolean, autoCursor?: boolean, syntaxLinter?: boolean, keywords?: readonly string[]} = {}) → LanguageSupport BibTeX language support with BibLaTeX dialect support, autocompletion configuration, and snippets for both BibTeX and BibLaTeX that are suggested based on the editor context.
There are configuration options for the following:
- BibTeX vs BibLaTeX language support:
- default:
biblatex: false - defaults to BibTeX
- default:
- Snippet Smart-Suggestion:
- default:
smartSuggest: true - The smart-suggestion feature only suggests snippets for bibliography
entries(i.e.@article = {...}) when the user is not currently editing an entry and only suggests snippets for bibliographyfields(i.e.author = {Donald Knuth}) when the user is currently editing an entry.
- default:
- Opinionated Snippets:
- default:
snippetRecs: true - Snippets have been scaffolded as per the current BibTeX/BibLaTeX specs. The snippet render config, exclusion of certain snippets, and entry snippets' suggestion of recommendation/optional fields are done in an opinionated manner (suggestions are welcome!).
- default:
- Automatic Cursor Placement:
- default:
autoCursor: true - Automatically place the cursor in ideal location(s) when expanding a snippet. This, as well, is opinionated.
- Please note that this feature relies on the cursor state (which is tracked by EditorState). When overwriting the EditorState (in a non user-input related manner, i.e. via a formatting plugin), the future cursor locations do not always persist, leading to a clunky (or sometimes fully inoperable) experience.
- Thus, if your CodeMirror implementation relies heavily on modifying/overwriting EditorState, I would recommend testing both with and without this feature, to see which works best for your use-case.
- (As an aside: I have some ideas on how to fix this issue, but I have just started a new semester at uni and will likely not have much time to work on the plugin for the next few months. - Vai)
- default:
- Syntax Linting:
- default:
syntaxLinter: true - Invalid BibTeX (and BibLaTeX) syntax is underlined in red and a warning is issued, thanks to bibtex-tidy.
- default:
- Custom Keywords:
- default:
keywords: [] - Users can specify custom keywords/values that will be auto-suggested when within a
FieldValuesyntax node.
- default:
- BibTeX vs BibLaTeX language support:
-
bibtexLanguage: LRLanguage BibTeX Language configuration with syntax highlighting, folding, and indentation.
-
biblatexLanguage: LRLanguage -
bibtexCompletion: Extension BibTeX autocompletion configuration.
-
bibtexLinter: Extension BibTeX syntax linter.