diff --git a/tests/test_github_issues.py b/tests/test_github_issues.py index 0aeba4d..fab0934 100644 --- a/tests/test_github_issues.py +++ b/tests/test_github_issues.py @@ -199,3 +199,114 @@ def test_github_issue_52(): '\n\t\t\t
this is the first line\n\nbut "quotes" in an ' + 'extended pre block need to be handled properly.') + assert result == expect + + # supplied input + test = ('''pre.. import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import ru.onyma.job.Context; +import ru.onyma.job.RescheduleTask; + +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; + +/** + * @author ustits + */ +public abstract class MainService
import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import ru.onyma.job.Context; +import ru.onyma.job.RescheduleTask; + +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; + +/** + * @author ustits + */ +public abstract class MainService<T> extends RescheduleTask implements Context<T> { + + private static final Logger log = LoggerFactory.getLogger(MainService.class); + private final ScheduledExecutorService scheduler; + + private boolean isFirstRun = true; + private T configs; + + public MainService(final ScheduledExecutorService scheduler) { + super(scheduler); + this.scheduler = scheduler; + } + + @Override + public void setConfig(final T configs) { + this.configs = configs; + if (isFirstRun) { + scheduler.schedule(this, 0, TimeUnit.SECONDS); + isFirstRun = false; + } + } + + @Override + public void stop() { + super.stop(); + scheduler.shutdown(); + try { + scheduler.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS); + } catch (InterruptedException ie) { + log.warn("Unable to wait for syncs termination", ie); + Thread.currentThread().interrupt(); + } + } + + protected final T getConfigs() { + return configs; + } +}''') + assert result == expect diff --git a/textile/core.py b/textile/core.py index efb1c4d..0e44234 100644 --- a/textile/core.py +++ b/textile/core.py @@ -506,7 +506,10 @@ def block(self, text): block.outer_atts) line = "\t{0}".format(line) else: - line = self.graf(line) + if block.tag == 'pre': + line = self.shelve(encode_html(line, quotes=True)) + else: + line = self.graf(line) line = self.doPBr(line) line = line.replace('