How to use the pyglossary.plugins.dsl.flawless_dsl.tag.Tag function in pyglossary

To help you get started, we’ve selected a few pyglossary examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ilius / pyglossary / pyglossary / plugins / dsl / flawless_dsl / main.py View on Github external
if chunk:
				yield TEXT, chunk

			if bracket == -1:
				break

			ptr = bracket
			# at least two chars after opening bracket:
			bracket = line.find("]", ptr + 2)
			if line[ptr + 1] == "/":
				yield CLOSE, line[ptr + 2:bracket]
			else:
				for tag, _, _, tag_open_re in self.tags:
					if re.match(tag_open_re, line[ptr:bracket + 1]):
						yield OPEN, _tag.Tag(line[ptr + 1:bracket], tag)
						break
				else:
					tag = line[ptr + 1:bracket]
					yield OPEN, _tag.Tag(tag, tag)
			ptr = bracket + 1
github ilius / pyglossary / pyglossary / plugins / dsl / flawless_dsl / layer.py View on Github external
:param tag: tag.Tag
		:return: bool
		"""
		return tag in self.tags

	def __repr__(self):
		return 'Layer({%s}, %r)' % (', '.join(map(str, self.tags)), self.text)

	def __eq__(self, other):
		"""
		mostly for unittest.
		"""
		return self.text == other.text and self.tags == other.tags


i_and_c = {tag.Tag('i', 'i'), tag.Tag('c', 'c')}
p_tag = tag.Tag('p', 'p')


def close_tags(stack, tags, layer_index=-1):
	"""
	close given tags on layer with index `layer_index`.

	:param stack: Iterable[Layer]
	:param layer_index: int
	:param tags: Iterable[tag.Tag]
	:return: None
	"""
	if layer_index == -1:
		layer_index = len(stack) - 1
	layer = stack[layer_index]
github ilius / pyglossary / pyglossary / plugins / dsl / flawless_dsl / layer.py View on Github external
:return: bool
		"""
		return tag in self.tags

	def __repr__(self):
		return 'Layer({%s}, %r)' % (', '.join(map(str, self.tags)), self.text)

	def __eq__(self, other):
		"""
		mostly for unittest.
		"""
		return self.text == other.text and self.tags == other.tags


i_and_c = {tag.Tag('i', 'i'), tag.Tag('c', 'c')}
p_tag = tag.Tag('p', 'p')


def close_tags(stack, tags, layer_index=-1):
	"""
	close given tags on layer with index `layer_index`.

	:param stack: Iterable[Layer]
	:param layer_index: int
	:param tags: Iterable[tag.Tag]
	:return: None
	"""
	if layer_index == -1:
		layer_index = len(stack) - 1
	layer = stack[layer_index]

	if layer.text:
github ilius / pyglossary / pyglossary / plugins / dsl / flawless_dsl / main.py View on Github external
if bracket == -1:
				break

			ptr = bracket
			# at least two chars after opening bracket:
			bracket = line.find("]", ptr + 2)
			if line[ptr + 1] == "/":
				yield CLOSE, line[ptr + 2:bracket]
			else:
				for tag, _, _, tag_open_re in self.tags:
					if re.match(tag_open_re, line[ptr:bracket + 1]):
						yield OPEN, _tag.Tag(line[ptr + 1:bracket], tag)
						break
				else:
					tag = line[ptr + 1:bracket]
					yield OPEN, _tag.Tag(tag, tag)
			ptr = bracket + 1