2021-03-19 21:07:45 +00:00
|
|
|
import cheerio from 'cheerio';
|
2021-04-21 16:14:44 +00:00
|
|
|
import prettier from 'prettier';
|
|
|
|
import { fileURLToPath } from 'url';
|
2021-04-12 15:20:58 +00:00
|
|
|
/** load html */
|
2021-03-19 21:07:45 +00:00
|
|
|
export function doc(html) {
|
|
|
|
return cheerio.load(html);
|
2021-03-26 19:14:32 +00:00
|
|
|
}
|
2021-04-21 16:14:44 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* format the contents of an astro file
|
|
|
|
* @param contents {string}
|
|
|
|
*/
|
|
|
|
export function format(contents) {
|
|
|
|
return prettier.format(contents, {
|
|
|
|
parser: 'astro',
|
|
|
|
plugins: [fileURLToPath(new URL('../prettier-plugin-astro', import.meta.url))]
|
|
|
|
})
|
|
|
|
}
|