Digested-Tile 2024-09-13
Authors:: Unknown License:: Unspecified Digest Root:: 23367bb564e3
MarkdownTile
deformatTile.js
function deformatTile(tile) {
if (typeof tile !== 'string') {
throw new Error('Deformat received non-string content');
}
const originalLength = tile.length;
// Remove Tile IDs at the end of lines
tile = tile.replace(/\s*\^[a-zA-Z0-9-]+$/gm, '');
// Remove Digest Tags at the very end of the tile
tile = tile.replace(/\s*#ds\/[a-f0-9]+\/\d{4}-\d{2}-\d{2}$/, '');
// Remove markdown headers
tile = tile.replace(/^#{1,6}\s+/gm, '');
// Replace ordered list markers with markdown list marker
tile = tile.replace(/^\s*\d+\.\s+/gm, '- ');
// Remove markdown comments
tile = tile.replace(//g, '');
// Collapse multiple newlines and trim
tile = tile.replace(/\n+/g, '\n').trim();
const charactersRemoved = originalLength - tile.length;
return { deformattedContent: tile, charactersRemoved };
}
module.exports = deformatTile;DeformattedTile
deformatTile.js
function deformatTile(tile) {
if (typeof tile !== 'string') {
throw new Error('Deformat received non-string content');
}
const originalLength = tile.length;
// Remove Tile IDs at the end of lines
tile = tile.replace(/\s*\^[a-zA-Z0-9-]+$/gm, '');
// Remove Digest Tags at the very end of the tile
tile = tile.replace(/\s*#ds\/[a-f0-9]+\/\d{4}-\d{2}-\d{2}$/, '');
// Remove markdown headers
tile = tile.replace(/^#{1,6}\s+/gm, '');
// Replace ordered list markers with markdown list marker
tile = tile.replace(/^\s*\d+\.\s+/gm, '- ');
// Remove markdown comments
tile = tile.replace(//g, '');
// Collapse multiple newlines and trim
tile = tile.replace(/\n+/g, '\n').trim();
const charactersRemoved = originalLength - tile.length;
return { deformattedContent: tile, charactersRemoved };
}
module.exports = deformatTile;