{"action":"opened","issue":{"url":"https://api.github.com/repos/bodil/eulalie/issues/60","repository_url":"https://api.github.com/repos/bodil/eulalie","labels_url":"https://api.github.com/repos/bodil/eulalie/issues/60/labels{/name}","comments_url":"https://api.github.com/repos/bodil/eulalie/issues/60/comments","events_url":"https://api.github.com/repos/bodil/eulalie/issues/60/events","html_url":"https://github.com/bodil/eulalie/issues/60","id":198245359,"number":60,"title":"How would `notString` work?","user":{"login":"ccorcos","id":1794527,"avatar_url":"https://avatars.githubusercontent.com/u/1794527?v=3","gravatar_id":"","url":"https://api.github.com/users/ccorcos","html_url":"https://github.com/ccorcos","followers_url":"https://api.github.com/users/ccorcos/followers","following_url":"https://api.github.com/users/ccorcos/following{/other_user}","gists_url":"https://api.github.com/users/ccorcos/gists{/gist_id}","starred_url":"https://api.github.com/users/ccorcos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ccorcos/subscriptions","organizations_url":"https://api.github.com/users/ccorcos/orgs","repos_url":"https://api.github.com/users/ccorcos/repos","events_url":"https://api.github.com/users/ccorcos/events{/privacy}","received_events_url":"https://api.github.com/users/ccorcos/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-12-31T20:14:34Z","updated_at":"2016-12-31T20:14:34Z","closed_at":null,"body":"I'm trying to make a markdown parser and I'm working on inline tokens for italic and bold using `*` and `**` to wrap a string. The thing is, you should be able to have italics inside bold and vice versa.\r\n\r\nBasically, if `*` or `**` are the tokens we're interested in, we want to make sure that there's a space before the start token and a space after the end token and we want the inside string the return value.\r\n\r\nHere's what I have prototyped so far:\r\n\r\n```js\r\nconst italic = seq(function*() {\r\n  yield char('*')\r\n  const firstChar = yield both([\r\n    notChar(' '),\r\n    notChar('*'),\r\n  ])\r\n  const {value: s} = yield many1(either([\r\n    seq(function* () {\r\n      yield char('\\\\')\r\n      yield item\r\n    }),\r\n    notString('* ')\r\n  ]))\r\n  yield char('*')\r\n  return s\r\n})\r\n```\r\n\r\nI tried creating `notString` from the `string` function but I think that's the wrong approach because I'm not sure I want `notString` to consume anything. \r\n\r\n```js\r\nfunction notString(s) {\r\n  return seq(function*() {\r\n    let i = 0\r\n    while(i < s.length) {\r\n      yield notChar(s[i])\r\n    }\r\n  })\r\n}\r\n```\r\n\r\nSo maybe I could write something like `notString('* ', item)` which means it will only consume on character at a time while checking ahead.\r\n\r\n```js\r\nfunction notString(s, after) {\r\n  return function(input) {\r\n    return input.startsWith(s) ? parse(input, after) : error(input)\r\n  }\r\n}\r\n```\r\n\r\nI'm pretty sure I can get something to work here, but I'm curious if you have any recommendations about the cleanest way to do this. One thing I haven't actually accounted for is nesting parsers, but I think that would be easier as a second pass over the result rather than composing each other...\r\n"}}
{"actor":{"display_login":"ccorcos"}}