Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Markdown indentation #31

Merged
merged 7 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,41 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p

## [Unreleased]

### Added

- `stripIndent` language config option

### Fixed

- Markdown indentation ([#13](https://github.com/harrydowning/yaml-embedded-languages/issues/13))
- Highlighting for new YAML grammar

### Changed

- Fully generated `package.json` to be partially generated

## [0.4.0] - 2024-08-18

### Added

- Option to specify language name in `yaml-embedded-languages.include` config.
- Option to specify language name in `yaml-embedded-languages.include` config

### Fixed

- Correct language names (Issue [#12](https://github.com/harrydowning/yaml-embedded-languages/issues/12))
- Built-in language names ([#12](https://github.com/harrydowning/yaml-embedded-languages/issues/12))

## [0.3.3] - 2024-07-06

### Changed

- Only update extension files on version update
- Extension to generate files on update
- Doc formatting and links

## [0.3.2] - 2024-07-06

### Fixed

- User languages reset on extension update (Issue [#24](https://github.com/harrydowning/yaml-embedded-languages/issues/24))
- User languages reset on extension update ([#24](https://github.com/harrydowning/yaml-embedded-languages/issues/24))
- User language override precedence

## [0.3.1] - 2024-06-29
Expand All @@ -40,19 +53,19 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p

### Added

- Support for Power Fx (Issue [#17](https://github.com/harrydowning/yaml-embedded-languages/issues/17))
- Support for Power Fx ([#17](https://github.com/harrydowning/yaml-embedded-languages/issues/17))

## [0.2.0] - 2023-07-29

### Added

- Issue [#9](https://github.com/harrydowning/yaml-embedded-languages/issues/9)
- Support for GitHub Actions ([#9](https://github.com/harrydowning/yaml-embedded-languages/issues/9))
- `CONTRIBUTING.md` documentation
- `-dev` flag on `extension.js`

### Fixed

- Issue [#7](https://github.com/harrydowning/yaml-embedded-languages/issues/7)
- Path separators on macOS ([#7](https://github.com/harrydowning/yaml-embedded-languages/issues/7))

### Changed

Expand Down
24 changes: 17 additions & 7 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ const LANGUAGES = {
latex: "text.tex",
lua: "source.lua",
makefile: "source.makefile",
markdown: "text.html.markdown",
markdown: {
scopeName: "text.html.markdown",
stripIndent: true,
},
objc: {
name: "objective-c",
scopeName: "source.objc",
Expand Down Expand Up @@ -149,7 +152,7 @@ const getPatterns = (languages) => {
const getRepository = (languages) => {
const entries = Object.entries(languages);
return Object.fromEntries(
entries.map(([id, { scopeName }]) => [
entries.map(([id, { scopeName, stripIndent }]) => [
`${id}-${REPOSITORY_SUFFIX}`,
{
begin: `(?i)(?:(\\|)|(>))([1-9])?([-+])?[ \t]+(#[ \t]*(?:${id})[ \t]*\\n)`,
Expand Down Expand Up @@ -184,6 +187,7 @@ const getRepository = (languages) => {
{
begin: "(?>^|\\G)([ ]+)(?! )",
end: "^(?!\\1|\\s*$)",
while: stripIndent ? "\\1" : undefined,
name: `${LANGUAGE_SCOPE_PREFIX}.${id}`,
patterns: [{ include: scopeName }],
},
Expand Down Expand Up @@ -221,14 +225,20 @@ const write = (filename, data) => {
const normalizeLanguages = (languages) => {
const normalizedLanguages = {};
for (const id in languages) {
const language = languages[id];
let language = languages[id];
if (typeof language === "string") {
language = { scopeName: language };
}

if (
typeof language === "object" &&
typeof language.scopeName === "string"
) {
normalizedLanguages[id] = {
name: id,
scopeName: language,
name: language.name || id,
scopeName: language.scopeName,
stripIndent: language.stripIndent || false,
};
} else {
normalizedLanguages[id] = language;
}
}
return normalizedLanguages;
Expand Down
Loading