Skip to content

Commit

Permalink
Merge pull request #122 from wrenger/lists
Browse files Browse the repository at this point in the history
Improve support for lists
  • Loading branch information
Clemens-E committed Feb 18, 2024
2 parents de8ef23 + e466cea commit 56fb599
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { LanguageToolPluginSettings } from './SettingsTab';
export const logs: string[] = [];

let lastStatus: 'ok' | 'request-failed' | 'request-not-ok' | 'json-parse-error' = 'ok';
const listRegex = /^\s*(-|\d+\.) $/m;

export async function getDetectionResult(
text: string,
Expand All @@ -19,8 +20,14 @@ export async function getDetectionResult(
if (/^`[^`]+`$/.test(text)) {
return text;
}
const linebreaks = '\n'.repeat((text.match(/\n/g) || [])?.length ?? 0);

return '\n'.repeat((text.match(/\n/g) || []).length);
// Support lists (annotation ends with marker)
if (listRegex.exec(text)) {
return `${linebreaks}• `; // this is the character, the online editor uses
}

return linebreaks;
},
});

Expand Down

0 comments on commit 56fb599

Please sign in to comment.