@adguard/agtree
Version:
Tool set for working with adblock filter lists
77 lines (76 loc) • 2.06 kB
TypeScript
import { type AnyCommentRule } from '../../nodes/index.js';
import { BaseParser } from '../base-parser.js';
/**
* `CommentParser` is responsible for parsing any comment-like adblock rules.
*
* @example
* Example rules:
* - Adblock agent rules:
* - ```adblock
* [AdGuard]
* ```
* - ```adblock
* [Adblock Plus 2.0]
* ```
* - etc.
* - AdGuard hint rules:
* - ```adblock
* !+ NOT_OPTIMIZED
* ```
* - ```adblock
* !+ NOT_OPTIMIZED PLATFORM(windows)
* ```
* - etc.
* - Pre-processor rules:
* - ```adblock
* !#if (adguard)
* ```
* - ```adblock
* !#endif
* ```
* - etc.
* - Metadata rules:
* - ```adblock
* ! Title: My List
* ```
* - ```adblock
* ! Version: 2.0.150
* ```
* - etc.
* - AGLint inline config rules:
* - ```adblock
* ! aglint-enable some-rule
* ```
* - ```adblock
* ! aglint-disable some-rule
* ```
* - etc.
* - Simple comments:
* - Regular version:
* ```adblock
* ! This is just a comment
* ```
* - uBlock Origin / "hostlist" version:
* ```adblock
* # This is just a comment
* ```
* - etc.
*/
export declare class CommentParser extends BaseParser {
/**
* Checks whether a rule is a comment.
*
* @param raw Raw rule
* @returns `true` if the rule is a comment, `false` otherwise
*/
static isCommentRule(raw: string): boolean;
/**
* Parses a raw rule as comment.
*
* @param raw Raw input to parse.
* @param options Global parser options.
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
* @returns Comment AST or null (if the raw rule cannot be parsed as comment)
*/
static parse(raw: string, options?: import("../index.js").ParserOptions, baseOffset?: number): AnyCommentRule | null;
}