aboutsummaryrefslogtreecommitdiff
path: root/textoutpc/builtin/_Quote.py
blob: d5430426417d2fc286ec5ee7b8e27465f13d1649 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python3
#******************************************************************************
# Copyright (C) 2018 Thomas "Cakeisalie5" Touhey <thomas@touhey.fr>
# This file is part of the textoutpc project, which is MIT-licensed.
#******************************************************************************

from .. import BlockTag as _BlockTag

__all__ = ["QuoteTag"]


class QuoteTag(_BlockTag):
	""" The main tag for quoting someone.
		Example uses:

		[quote]Hey, I said that![/quote]
		[quote=Someone important]I said something important, and it's
		multiline and [b]formatted[/b]!
		[quote=Someone else]Heck, he's even quoting me in his quote![/quote]
		[/quote]
	"""

	aliases = ('[quote]',)
	superblock = True
	notempty = True
	procvalue = True

	def prepare(self, name, value):
		self._value = value

	def begin_html(self):
		f = '<div class="citation">'
		if self._value:
			f += '<p><b>{} a écrit :</b></p>'.format(self._value)
		return f

	def end_html(self):
		return '</div>'

	def begin_lightscript(self):
		text = '<<<'
		if self._value:
			text += ' ' + self._value
		return text + '\n'

	def end_lightscript(self):
		return '<<<\n'

# End of file.