Add search syntax
This commit is contained in:
@@ -75,6 +75,13 @@ const handlers = {
|
||||
a.href = url;
|
||||
a.textContent = url;
|
||||
document.body.appendChild(a);
|
||||
},
|
||||
|
||||
search({ document }, { content, query }) {
|
||||
const a = document.createElement('a');
|
||||
a.href = `https://www.google.com/?#q=${query}`;
|
||||
a.textContent = content;
|
||||
document.body.appendChild(a);
|
||||
}
|
||||
};
|
||||
|
||||
|
13
src/text/parse/elements/search.ts
Normal file
13
src/text/parse/elements/search.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* Search
|
||||
*/
|
||||
|
||||
module.exports = text => {
|
||||
const match = text.match(/^(.+?) 検索(\n|$)/);
|
||||
if (!match) return null;
|
||||
return {
|
||||
type: 'search',
|
||||
content: match[0],
|
||||
query: match[1]
|
||||
};
|
||||
};
|
Reference in New Issue
Block a user