Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose grammar object for customisation #103

Merged
merged 2 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,18 @@ sdpTransform.write(res).split('\r\n'); // res parsed above

The only thing different from the original input is we follow the order specified by the SDP RFC, and we will always do so.

## Usage - Custom grammar

In case you need to add custom grammar (e.g. add unofficial attributes) to the parser, you can do so by mutating the `grammar` object before parsing.

```js
sdpTransform.grammar['a'].push({
name: 'xCustomTag',
reg: /^x-custom-tag:(\d*)/,
names: ['tagId'],
format: 'x-custom-tag:%d
})
```

## License

Expand Down
2 changes: 2 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
var parser = require('./parser');
var writer = require('./writer');
var grammar = require('./grammar');

exports.grammar = grammar;
exports.write = writer;
exports.parse = parser.parse;
exports.parseParams = parser.parseParams;
Expand Down
Loading