textile / python-textile

A Python port of Textile, A humane web text generator
Other
68 stars 23 forks source link

Incorrect handling of quote entities in extended pre block #55

Closed tynopet closed 6 years ago

tynopet commented 6 years ago

Hello, I try to wrap this text:

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<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;
  }
}

and I getting this result:

<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<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(&#8220;Unable to wait for syncs termination&#8221;, ie);
      Thread.currentThread().interrupt();
    }
  }

  protected final T getConfigs() {
    return configs;
  }
}</pre>

but on txstyle.org I getting this result:

<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&lt;T&gt; extends RescheduleTask implements Context&lt;T&gt; {

  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(&quot;Unable to wait for syncs termination&quot;, ie);
      Thread.currentThread().interrupt();
    }
  }

  protected final T getConfigs() {
    return configs;
  }
}</pre>

Difference in parse ". Python parser return ”, php parser return ". &#8221 in not transform in > within pre tag.

ikirudennis commented 6 years ago

Thanks for this. I can see the issue, and while I usually like to use the text provided by users in issues to test against, in this case it can be reduced quite a bit while exposing the problem:

pre.. this is the first line

but "quotes" in an extended pre block need to be handled properly.

Should be rendered as:

<pre>this is the first line

but &quot;quotes&quot; in an extended pre block need to be handled properly.</pre>

Hopefully, I can sort this out relatively easily.

ikirudennis commented 6 years ago

Actually, your test is more complete. There are issues with the angle brackets as well. Committing a fix shortly.

tynopet commented 6 years ago

Thank you!

ikirudennis commented 6 years ago

This was merged into version 3.0.0