Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: dd86d47b4c3d0e1c0f3f0fc702c7f80d9336fb6f (plain) (blame)
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
50
51
52
53
/*******************************************************************************
 * Copyright (c) 2013 Stefan Seelmann and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Stefan Seelmann - initial API and implementation
 *******************************************************************************/

package org.eclipse.mylyn.internal.wikitext.markdown.core;

import org.eclipse.mylyn.wikitext.core.parser.markup.ContentState;

/**
 * Extended version of ContentState that preprocesses Markdown for reference-style link support.
 * 
 * @author Stefan Seelmann
 */
public class MarkdownContentState extends ContentState {

	private LinkDefinitionParser linkDefinitionParser;

	private LinkDefinitionUsageTracker linkDefinitionUsageTracker;

	@Override
	protected void setMarkupContent(String markupContent) {
		super.setMarkupContent(markupContent);

		linkDefinitionParser = new LinkDefinitionParser();
		linkDefinitionParser.parse(markupContent);

		linkDefinitionUsageTracker = new LinkDefinitionUsageTracker(this, linkDefinitionParser);
	}

	/**
	 * Gets the {@link LinkDefinition} for the given link identifier, or <code>null</code> if there is no such
	 * {@link LinkDefinition}.
	 * 
	 * @param id
	 *            the link identifier.
	 * @return the {@link LinkDefinition} or <code>null</code>
	 */
	public LinkDefinition getLinkDefinition(String id) {
		linkDefinitionUsageTracker.linkDefinitionRequested(id);
		return linkDefinitionParser.getLinkDefinition(id);
	}

	public LinkDefinitionUsageTracker getLinkDefinitionUsageTracker() {
		return linkDefinitionUsageTracker;
	}
}

Back to the top