def tokenise(string, strict=False, replace=False,
						diphtongs=False, tones=False, unknown=False, merge=None):
	"""
	Tokenise an IPA string into a list of tokens. Raise ValueError if there is
	a problem; if strict=True, this includes the string not being compliant to
	the IPA spec.

	If replace=True, replace some common non-IPA symbols with their IPA
	counterparts. If diphtongs=True, try to group diphtongs into single tokens.
	If tones=True, do not ignore tone symbols. If unknown=True, do not ignore
	symbols that cannot be classified into a relevant category. If merge is not
	None, use it for within-word token grouping.

	Part of ipatok's public API.
	"""
	words = string.strip().replace('_', ' ').split()
	output = []

	for word in words:
		tokens = tokenise_word(word, strict, replace, tones, unknown)

		if diphtongs:
			tokens = group(are_diphtong, tokens)

		if merge is not None:
			tokens = group(merge, tokens)

		output.extend(tokens)

	return output