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

`@else/url` blocking type recognition #104

Closed
larsgw opened this Issue Dec 17, 2017 · 1 comment

Comments

Projects
1 participant
@larsgw
Owner

larsgw commented Dec 17, 2017

For example, @else/url currently blocks type recognition of other URL-like types added after it is added, and it's added at initialisation. Already existing workarounds:

  • disable the type parser of @else/url
Cite.parse.add('@else/url', {dataType: 'String', parseType: () => false})
  • use the forceType option or Cite.parse.data[Async]() with the desired type
Cite.input(data, {forceType: '@other/url+type'})
Cite.parse.data(data, '@other/url+type')

A general solution would be to create a separate category of parsers with generic types, to catch all leftovers. This would include all @else and @empty types. This could also warrant the creation of an entire category system for parsers, as there already is a separate system for native parsers.

@larsgw larsgw added the bug label Dec 17, 2017

@larsgw larsgw self-assigned this Dec 17, 2017

@larsgw larsgw added this to TODO in Version 0.4 Dec 19, 2017

@larsgw larsgw moved this from TODO to In Progress in Version 0.4 Dec 19, 2017

@larsgw

This comment has been minimized.

Show comment
Hide comment
@larsgw

larsgw Apr 22, 2018

Owner

I'm working on a different system: types will now be able to extend other types. Example:

Cite.parse.add('@wikidata/url', {
  dataType: 'String',
  parseType: () => false,
  extends: '@else/url'
})

The Cite.parse.add() function will probably also change before v0.4.0, but that's for another day.

This will register @wikidata/url as a subclass of @else/url. If a given input matches @else/url, it will now first check if subclasses also match, and if they do, give it that type. Note that this assumes every form of input matching @wikidata/url also matches @else/url, i.e.:

venn citation js

If types (or rather the criteria in the type parsers) overlap, however, this wouldn't work.

venn citation js 1

In that case, I recommend making the type parser criteria more specific, if possible.


Note: Removing parsers (instead of stubbing them, like above) will also be possible.

I still have to figure out logic for what happens when a type is registered as extending a type that doesn't exist.

Owner

larsgw commented Apr 22, 2018

I'm working on a different system: types will now be able to extend other types. Example:

Cite.parse.add('@wikidata/url', {
  dataType: 'String',
  parseType: () => false,
  extends: '@else/url'
})

The Cite.parse.add() function will probably also change before v0.4.0, but that's for another day.

This will register @wikidata/url as a subclass of @else/url. If a given input matches @else/url, it will now first check if subclasses also match, and if they do, give it that type. Note that this assumes every form of input matching @wikidata/url also matches @else/url, i.e.:

venn citation js

If types (or rather the criteria in the type parsers) overlap, however, this wouldn't work.

venn citation js 1

In that case, I recommend making the type parser criteria more specific, if possible.


Note: Removing parsers (instead of stubbing them, like above) will also be possible.

I still have to figure out logic for what happens when a type is registered as extending a type that doesn't exist.

larsgw added a commit that referenced this issue Apr 23, 2018

[input] Rework input system again
# Feature
- 'extends' type parsing option, to subclass
  types (like @else/url -> @wikidata/api).
  See #104

# Change
- Type parsers now go in a seperate 'parseType'
  option
- Renamed 'parseType' predicate option to
  'predicate'

# Refactoring
- Refactor the registering system
- Improve the backwards compat system

See #104, #106, #88

@larsgw larsgw closed this in a156afe Apr 28, 2018

Version 0.4 automation moved this from In Progress to Done Apr 28, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment